diff --git a/app/documentation/docs/[version]/[slug]/page.tsx b/app/documentation/docs/[version]/[slug]/page.tsx index e4f7287..3456529 100644 --- a/app/documentation/docs/[version]/[slug]/page.tsx +++ b/app/documentation/docs/[version]/[slug]/page.tsx @@ -33,7 +33,7 @@ const initIndexJSON = async (version: string) => { if (!indexJSON) { indexJSON = {}; } - indexJSON[version] = await getVersionIndex(version); + indexJSON[version] = await getVersionIndex(version, true); } } diff --git a/lib/utils.ts b/lib/utils.ts index dd75f87..a9074f6 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -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; }