From 7082a50f50f2e8df5e73f8e38fba9aecd2531b1a Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:21:40 -0600 Subject: [PATCH 1/6] Slim the C# API reference sidebar to a per-page spine Each C# package/type/member-kind page now server-renders only the search link, package overview and the current type's member-kind links. The full package tree is emitted once per package as /reference/api/csharp/{pkg}/sidebar.json and swapped in on the client by cloning the spine's own SidebarSublist markup, reusing Starlight's sl-sidebar-state persistence. The C# landing sidebar now links to packages instead of embedding every tree. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../src/components/starlight/Sidebar.astro | 18 ++ .../components/starlight/api-sidebar-tree.ts | 211 ++++++++++++++++++ .../[package]/[type]/[memberKind].astro | 2 +- .../api/csharp/[package]/[type]/index.astro | 2 +- .../api/csharp/[package]/sidebar.json.ts | 43 ++++ src/frontend/src/utils/api-sidebar.ts | 160 ++++++++----- .../tests/e2e/csharp-api-sidebar.spec.ts | 104 +++++++++ .../tests/unit/api-sidebar.vitest.test.ts | 139 ++++++++++++ 8 files changed, 619 insertions(+), 60 deletions(-) create mode 100644 src/frontend/src/components/starlight/api-sidebar-tree.ts create mode 100644 src/frontend/src/pages/reference/api/csharp/[package]/sidebar.json.ts create mode 100644 src/frontend/tests/e2e/csharp-api-sidebar.spec.ts create mode 100644 src/frontend/tests/unit/api-sidebar.vitest.test.ts diff --git a/src/frontend/src/components/starlight/Sidebar.astro b/src/frontend/src/components/starlight/Sidebar.astro index b4c6333d65..5dc895931c 100644 --- a/src/frontend/src/components/starlight/Sidebar.astro +++ b/src/frontend/src/components/starlight/Sidebar.astro @@ -22,6 +22,12 @@ const apiLang = pageId.startsWith('reference/api/typescript') : undefined; const sidebar = routeData?.sidebar ?? []; const topics = topicState?.topics ?? []; +// C# package pages render a small spine; the full package tree loads on the client. +const csharpPackageSlug = + apiLang === 'csharp' ? Astro.url.pathname.match(/\/reference\/api\/csharp\/([^/]+)\//)?.[1] : undefined; +const apiSidebarTreeSrc = csharpPackageSlug + ? `${import.meta.env.BASE_URL.replace(/\/$/, '')}/reference/api/csharp/${csharpPackageSlug}/sidebar.json` + : undefined; type SidebarTopicOption = { label: string; @@ -122,6 +128,7 @@ const hasTopicsList = Boolean(currentTopic && effectiveTopics.length > 0); class="topics-sidebar" data-api-ref={isApiRefPage || undefined} data-api-lang={apiLang} + data-api-sidebar-tree={apiSidebarTreeSrc} data-topic-nav={hasTopicSidebar || undefined} > @@ -1246,6 +1253,10 @@ const hasTopicsList = Boolean(currentTopic && effectiveTopics.length > 0);