Skip to content

Commit

Permalink
Merge pull request #119 from DenverCoder544/documentation_version_reload
Browse files Browse the repository at this point in the history
bring back fetchHtmlContent - flag
  • Loading branch information
ZakarFin authored Sep 10, 2024
2 parents de66df7 + 07bfc6f commit d506581
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/documentation/docs/[version]/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const initIndexJSON = async (version: string) => {
if (!indexJSON) {
indexJSON = {};
}
indexJSON[version] = await getVersionIndex(version);
indexJSON[version] = await getVersionIndex(version, true);
}
}

Expand Down
16 changes: 9 additions & 7 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ function compileMarkdownToHTML(markdown: string, startingSectionNumber: string):
anchorLinks,
}
}
export async function getVersionIndex(version: string) {
export async function getVersionIndex(version: string, fetchHtmlContent: boolean = false) {
const rootFolder = `_content/docs/${version}`;
if (!fs.existsSync(rootFolder) || !fs.statSync(rootFolder).isDirectory()) {
return null;
}
const indexJSON = (await import(`_content/docs/${version}/index.js`)).default;

const imagesRuntimePath = '/assets/docs/' + version + '/resources/';
await indexJSON.forEach(async (element: MarkdownFileMetadata) => {
const { html, anchorLinks } = await readAndConcatMarkdownFiles(element, imagesRuntimePath, indexJSON, element.title);
element.anchorLinks = anchorLinks;
element.html = html;
});
if (fetchHtmlContent) {
const imagesRuntimePath = '/assets/docs/' + version + '/resources/';
await indexJSON.forEach(async (element: MarkdownFileMetadata) => {
const { html, anchorLinks } = await readAndConcatMarkdownFiles(element, imagesRuntimePath, indexJSON, element.title);
element.anchorLinks = anchorLinks;
element.html = html;
});
}

return indexJSON;
}
Expand Down

0 comments on commit d506581

Please sign in to comment.