From ef66ff8f993c9374e53adf6b12fd76452980eb38 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 11 Mar 2025 16:48:01 +0200 Subject: [PATCH] docs: improvement to sidebar (#11810) * docs: improvement to sidebar * fix sidebar --- www/apps/book/generated/sidebar.mjs | 32 ++++++++++--------- www/apps/book/sidebar.mjs | 23 +++++++------ .../docs-ui/src/providers/Sidebar/index.tsx | 4 +-- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/www/apps/book/generated/sidebar.mjs b/www/apps/book/generated/sidebar.mjs index fe3fba74fe..2997117583 100644 --- a/www/apps/book/generated/sidebar.mjs +++ b/www/apps/book/generated/sidebar.mjs @@ -1148,18 +1148,17 @@ export const generatedSidebars = [ "type": "link", "path": "/learn/build", "title": "Build", - "chapterTitle": "8. Production", + "children": [], + "chapterTitle": "8.1. Build", + "number": "8.1." + }, + { + "loaded": true, + "isPathHref": true, + "type": "link", + "path": "/learn/deployment", + "title": "Deployment Overview", "children": [ - { - "loaded": true, - "isPathHref": true, - "type": "link", - "path": "/learn/deployment", - "title": "Deployment Overview", - "children": [], - "chapterTitle": "8.1. Deployment Overview", - "number": "8.1." - }, { "loaded": true, "isPathHref": true, @@ -1167,13 +1166,16 @@ export const generatedSidebars = [ "path": "/learn/deployment/general", "title": "General Deployment", "children": [], - "chapterTitle": "8.2. General Deployment", - "number": "8.2." + "chapterTitle": "8.2.1. General Deployment", + "number": "8.2.1." } ], - "number": "8." + "chapterTitle": "8.2. Deployment Overview", + "number": "8.2." } - ] + ], + "chapterTitle": "8. Production", + "number": "8." }, { "loaded": true, diff --git a/www/apps/book/sidebar.mjs b/www/apps/book/sidebar.mjs index fd2ef094b4..bd146ab621 100644 --- a/www/apps/book/sidebar.mjs +++ b/www/apps/book/sidebar.mjs @@ -597,20 +597,25 @@ export const sidebars = [ ], }, { - type: "link", - path: "/learn/build", - title: "Build", - chapterTitle: "Production", + type: "category", + title: "Production", children: [ + { + type: "link", + path: "/learn/build", + title: "Build", + }, { type: "link", path: "/learn/deployment", title: "Deployment Overview", - }, - { - type: "link", - path: "/learn/deployment/general", - title: "General Deployment", + children: [ + { + type: "link", + path: "/learn/deployment/general", + title: "General Deployment", + }, + ], }, ], }, diff --git a/www/packages/docs-ui/src/providers/Sidebar/index.tsx b/www/packages/docs-ui/src/providers/Sidebar/index.tsx index 45dea243bc..cd6875734b 100644 --- a/www/packages/docs-ui/src/providers/Sidebar/index.tsx +++ b/www/packages/docs-ui/src/providers/Sidebar/index.tsx @@ -301,7 +301,7 @@ export const SidebarProvider = ({ }, [scrollableElement, isBrowser]) const activeMainSidebar = useMemo(() => { - if (!activePath) { + if (!activePath || sidebars.length === 1) { // set first sidebar as active return sidebars[0] } @@ -357,7 +357,7 @@ export const SidebarProvider = ({ const shownSidebar = useMemo(() => { if (!sidebarHistory.length) { - return + return sidebars.length === 1 ? sidebars[0] : undefined } return getSidebar(sidebarHistory[sidebarHistory.length - 1])