diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index b7b65be..94de770 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -7,6 +7,10 @@ const basePath: string = Astro.props.basePath; const entryPath = is_index_file(entry.path)? "": entry.path; const entryUrl = basePath + entryPath + (entryPath.endsWith("/")? "" : "/"); +console.table({ + basePath, + entryPath, +}) function is_index_file(p) { return p.endsWith("index") @@ -38,7 +42,7 @@ function is_index_file(p) { {entry.children!.map((nextEntry) => ( ))} diff --git a/src/layouts/NewDocsLayout.astro b/src/layouts/NewDocsLayout.astro index 8fb7754..16c5934 100644 --- a/src/layouts/NewDocsLayout.astro +++ b/src/layouts/NewDocsLayout.astro @@ -69,8 +69,6 @@ for (const post of posts_2) { } } -console.log(JSON.stringify(second_level, null, 4)); - // transform to the layout that the sidebar expects const entries = []; @@ -80,13 +78,22 @@ for (const levels_key in second_level) { const posts = second_level[levels_key]; entries.push(...posts) } + else { + const posts = second_level[levels_key]; + const parentEntry = { + path: "", + title: levels_key, + children: posts, + }; + entries.push(parentEntry); + } } - -const index_page = posts_2.find(post => post.relative_file === "/index.md" || post.relative_file === "/index.mdx"); +const index_page = entries.find(post => post.relative_file === "/index.md" || post.relative_file === "/index.mdx"); const basePath = index_page.url; -const pagesIndex = posts_2; +console.log(JSON.stringify(index_page, null, 4)); +console.log(basePath); ---