fix: Correct typo in snippet file name and add error handling

This commit is contained in:
Gauthier Daniels 2025-04-13 16:58:49 +02:00
parent 2eb8cff6e3
commit d95f43fcc4
2 changed files with 8 additions and 4 deletions

View File

@ -97,7 +97,7 @@ Ensuite, on va définir notre état initial :
{% tabs defaultSelectedTab="js" %}
{% tab value="js" label="JavaScript" %}
{% snippet path="react/reducer/reducer-initial-statse.js" language="js" /%}
{% snippet path="react/reducer/reducer-initial-state.js" language="js" /%}
{% /tab %}

View File

@ -91,9 +91,13 @@ class DocsService {
const [snippetsToFetch, allSnippets] = identifierResults;
for (const snippet of snippetsToFetch) {
try {
const absolutePath = path.resolve(DocsService.SNIPPETS_PATH, snippet);
const content = fs.readFileSync(absolutePath, "utf-8");
snippetsService.setToCache(snippet, content);
} catch (error) {
console.error(`Error reading snippet file ${snippet}:`, error);
}
}
return allSnippets || [];