Skip to content

Commit

Permalink
docs(website): show same sidebar on all pages (#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
xDivisionByZerox authored Apr 29, 2024
1 parent 425e10f commit f2bf707
Showing 1 changed file with 49 additions and 84 deletions.
133 changes: 49 additions & 84 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,71 @@ 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',
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',
Expand All @@ -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;
}

Expand Down Expand Up @@ -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'),
},
},

Expand Down

0 comments on commit f2bf707

Please sign in to comment.