diff options
| author | DivisionByZero <[email protected]> | 2024-04-29 09:41:24 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-29 07:41:24 +0000 |
| commit | f2bf7077ff7d8f145f1cb65cf234c40f3d3b8705 (patch) | |
| tree | d20ac56884abbb4165f6a26018db2f40377087c0 | |
| parent | 425e10fe1cfeff74b04a7ed931241625e951f33c (diff) | |
| download | faker-f2bf7077ff7d8f145f1cb65cf234c40f3d3b8705.tar.xz faker-f2bf7077ff7d8f145f1cb65cf234c40f3d3b8705.zip | |
docs(website): show same sidebar on all pages (#2855)
| -rw-r--r-- | docs/.vitepress/config.ts | 133 |
1 files changed, 49 insertions, 84 deletions
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e92efc8e..3bb9c935 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -14,25 +14,44 @@ const description = 'Generate massive amounts of fake (but reasonable) data for testing and development.'; const image = 'https://fakerjs.dev/social-image.png'; -function extendSideNav(current: SidebarItem): SidebarItem[] { +function getSideBarWithExpandedEntry(entryToExpand: string): SidebarItem[] { const links: SidebarItem[] = [ { text: 'Guide', items: [ { - text: 'Usage Guide', + text: 'Getting Started', link: '/guide/', }, + { + text: 'Usage', + link: '/guide/usage', + }, + { + text: 'Localization', + link: '/guide/localization', + }, + { + text: 'Frameworks', + link: '/guide/frameworks', + }, + { + text: 'Randomizer', + link: '/guide/randomizer', + }, + { + text: 'Unique Values', + link: '/guide/unique', + }, + { + text: 'Upgrading to v9', + link: '/guide/upgrading', + }, ], }, { text: 'API', - items: [ - { - text: 'API Reference', - link: '/api/', - }, - ], + items: apiPages, }, { text: 'About', @@ -40,10 +59,26 @@ function extendSideNav(current: SidebarItem): SidebarItem[] { { text: 'Announcements', link: '/about/announcements', + items: [ + { text: '2022-09-08', link: '/about/announcements/2022-09-08' }, + { text: '2022-01-14', link: '/about/announcements/2022-01-14' }, + ], }, { text: 'Roadmap', link: '/about/roadmap/', + items: [ + { + text: 'v9 - Tree-Shakeable Module-Functions', + link: '/about/roadmap/v9', + }, + { text: 'v8 - Make Faker Handier', link: '/about/roadmap/v8' }, + { + text: 'v7 - Cleanup & Improvements', + link: '/about/roadmap/v7', + }, + { text: 'v6 - Continue Faker', link: '/about/roadmap/v6' }, + ], }, { text: 'Team', @@ -56,7 +91,9 @@ function extendSideNav(current: SidebarItem): SidebarItem[] { ], }, ]; - links[links.findIndex((group) => group.text === current.text)] = current; + for (const entry of links) { + entry.collapsed = entry.text !== entryToExpand; + } return links; } @@ -197,81 +234,9 @@ const config: UserConfig<DefaultTheme.Config> = { ], sidebar: { - '/guide/': extendSideNav({ - text: 'Guide', - items: [ - { - text: 'Getting Started', - link: '/guide/', - }, - { - text: 'Usage', - link: '/guide/usage', - }, - { - text: 'Localization', - link: '/guide/localization', - }, - { - text: 'Frameworks', - link: '/guide/frameworks', - }, - { - text: 'Randomizer', - link: '/guide/randomizer', - }, - { - text: 'Unique Values', - link: '/guide/unique', - }, - { - text: 'Upgrading to v9', - link: '/guide/upgrading', - }, - ], - }), - '/api/': extendSideNav({ - text: 'API', - items: apiPages, - }), - - '/about/': extendSideNav({ - text: 'About', - items: [ - { - text: 'Announcements', - link: '/about/announcements', - items: [ - { text: '2022-09-08', link: '/about/announcements/2022-09-08' }, - { text: '2022-01-14', link: '/about/announcements/2022-01-14' }, - ], - }, - { - text: 'Roadmap', - link: '/about/roadmap/', - items: [ - { - text: 'v9 - Tree-Shakeable Module-Functions', - link: '/about/roadmap/v9', - }, - { text: 'v8 - Make Faker Handier', link: '/about/roadmap/v8' }, - { - text: 'v7 - Cleanup & Improvements', - link: '/about/roadmap/v7', - }, - { text: 'v6 - Continue Faker', link: '/about/roadmap/v6' }, - ], - }, - { - text: 'Team', - link: '/about/team', - }, - { - text: 'Contributing', - link: '/about/contributing', - }, - ], - }), + '/guide/': getSideBarWithExpandedEntry('Guide'), + '/api/': getSideBarWithExpandedEntry('API'), + '/about/': getSideBarWithExpandedEntry('About'), }, }, |
