From aca327391573abd6569792ac1e3cb95d08a45fde Mon Sep 17 00:00:00 2001 From: AJ Matthews Date: Tue, 31 Mar 2026 17:26:39 +0100 Subject: [PATCH 1/2] Initial attempt. --- src/frontend/astro.config.mjs | 1 + src/frontend/config/icon-packs.mjs | 13 +- .../starlight/TableOfContents.astro | 402 ++++++++++++++++++ .../src/components/starlight/TocList.astro | 55 +++ .../docs/get-started/prerequisites.mdx | 6 +- 5 files changed, 470 insertions(+), 7 deletions(-) create mode 100644 src/frontend/src/components/starlight/TableOfContents.astro create mode 100644 src/frontend/src/components/starlight/TocList.astro diff --git a/src/frontend/astro.config.mjs b/src/frontend/astro.config.mjs index 98cf1de7c..8fe74c2ab 100644 --- a/src/frontend/astro.config.mjs +++ b/src/frontend/astro.config.mjs @@ -52,6 +52,7 @@ export default defineConfig({ components: { Banner: './src/components/starlight/Banner.astro', EditLink: './src/components/starlight/EditLink.astro', + TableOfContents: './src/components/starlight/TableOfContents.astro', Footer: './src/components/starlight/Footer.astro', Head: './src/components/starlight/Head.astro', Header: './src/components/starlight/Header.astro', diff --git a/src/frontend/config/icon-packs.mjs b/src/frontend/config/icon-packs.mjs index 3e852800a..85aaaef9a 100644 --- a/src/frontend/config/icon-packs.mjs +++ b/src/frontend/config/icon-packs.mjs @@ -1,21 +1,22 @@ // Icon packs configuration for Mermaid diagrams. -// astro-mermaid now serializes icon packs as name/url pairs, so custom packs -// must be served from a static JSON endpoint instead of an inline loader. +// astro-mermaid@1.3.1 serializes each pack's `loader` function to a string at +// build time and reconstructs it on the client with `new Function(...)()`, so +// each pack must expose a `loader` arrow function (not a `url` string). export const iconPacks = [ { // Search: https://icon-sets.iconify.design/logos/?keyword=svg+logos name: 'logos', - url: 'https://unpkg.com/@iconify-json/logos@1/icons.json', + loader: () => fetch('https://unpkg.com/@iconify-json/logos@1/icons.json').then((r) => r.json()), }, { // Search: https://icon-sets.iconify.design/iconoir/?keyword=iconoir name: 'iconoir', - url: 'https://unpkg.com/@iconify-json/iconoir@1/icons.json', + loader: () => fetch('https://unpkg.com/@iconify-json/iconoir@1/icons.json').then((r) => r.json()), }, { - // Custom Aspire icons are served from the public folder for safe serialization. + // Custom Aspire icons are served from the public folder. name: 'aspire', - url: '/icons/aspire.json', + loader: () => fetch('/icons/aspire.json').then((r) => r.json()), }, ]; diff --git a/src/frontend/src/components/starlight/TableOfContents.astro b/src/frontend/src/components/starlight/TableOfContents.astro new file mode 100644 index 000000000..eb6da4352 --- /dev/null +++ b/src/frontend/src/components/starlight/TableOfContents.astro @@ -0,0 +1,402 @@ +--- +/** + * Override of @astrojs/starlight TableOfContents. + * + * Adds an AppHost language selector (C# / TypeScript) to the top of the TOC. + * The selector is only shown on pages that contain `[data-pivot-block="csharp"]` + * or `[data-pivot-block="typescript"]` elements (authored with the component). + * + * When active: + * - TOC entries whose target heading lives inside a hidden pivot block are hidden. + * - Changing the selector delegates to PivotSelector's button click (when present), + * keeping the existing PivotSelector behavior completely intact. + * - A MutationObserver watches pivot-block visibility changes driven by PivotSelector + * and keeps the TOC dropdown and filtered entries in sync. + */ +import TocList from './TocList.astro'; + +interface TocItem { + slug: string; + text: string; + children: TocItem[]; + depth: number; +} + +const { toc } = Astro.locals.starlightRoute; +--- + +{ + toc && ( + + + + ) +} + + + + diff --git a/src/frontend/src/components/starlight/TocList.astro b/src/frontend/src/components/starlight/TocList.astro new file mode 100644 index 000000000..15e02b95b --- /dev/null +++ b/src/frontend/src/components/starlight/TocList.astro @@ -0,0 +1,55 @@ +--- +/** + * Replicates @astrojs/starlight TableOfContentsList for the desktop TOC. + * The mobile TOC (MobileTableOfContents) is not overridden and continues to + * use Starlight's original implementation. + */ +interface TocItem { + slug: string; + text: string; + children: TocItem[]; + depth: number; +} + +interface Props { + toc: TocItem[]; + depth?: number; +} + +const { toc, depth = 0 } = Astro.props; +--- + + + + diff --git a/src/frontend/src/content/docs/get-started/prerequisites.mdx b/src/frontend/src/content/docs/get-started/prerequisites.mdx index f0624a11a..c333764f3 100644 --- a/src/frontend/src/content/docs/get-started/prerequisites.mdx +++ b/src/frontend/src/content/docs/get-started/prerequisites.mdx @@ -4,7 +4,7 @@ description: Learn about essential tooling concepts for Aspire. giscus: false tableOfContents: minHeadingLevel: 1 - maxHeadingLevel: 4 + maxHeadingLevel: 5 lastUpdated: true --- @@ -33,6 +33,8 @@ Ready to dive into Aspire? Before you begin, make sure your development environm + ##### .NET SDK + Aspire's C# AppHost is built on .NET, a free, open-source, cross-platform framework for building modern apps and cloud services. You'll need the [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) installed—no prior C# experience is required.