Starlight Sidebar Topics
Version :
starlight-sidebar-topics@0.9.0Starlight :@astrojs/starlight@0.42.4Intégré le : 2026-10-13 Doc officielle : https://starlight-sidebar-topics.netlify.app
1. Objectif
Section titled â1. ObjectifâOrganiser le sidebar de la documentation en topics thĂ©matiques cliquables. Chaque topic reprĂ©sente un domaine technique (Astro, Cloudflare, SanityâŠ) et affiche sa propre arborescence de navigation quand il est sĂ©lectionnĂ©.
2. Installation
Section titled â2. Installationâpnpm add starlight-sidebar-topics3. Configuration dans astro.config.mjs
Section titled â3. Configuration dans astro.config.mjsâLe plugin sâajoute dans le tableau plugins de starlight({}).
Important : la propriĂ©tĂ© racine sidebar: [...] de starlight doit ĂȘtre supprimĂ©e â le plugin la remplace entiĂšrement.
import starlightSidebarTopics from 'starlight-sidebar-topics';
starlight({ // PAS de sidebar: [...] ici plugins: [ starlightSidebarTopics( [ // Topic 1 â entrĂ©e manuelle { label: "Vue d'ensemble", link: '/docs/', icon: 'information', items: [ { label: 'Accueil de la Documentation', link: '/docs/' }, ], }, // Topic 2 â autogĂ©nĂ©rĂ© depuis un rĂ©pertoire { label: 'Getting Started', link: '/gettingstarted/01-setup-local/', icon: 'rocket', badge: { text: 'đ', variant: 'caution' }, items: [{ autogenerate: { directory: 'gettingStarted' } }], }, // Topic 3 â avec sous-groupes { label: 'Cloudflare', link: '/docs/l3_backend/cloudflare/config/configobjectdata/', icon: 'cloudflare', items: [ { label: 'L1 Contenu', items: [{ autogenerate: { directory: 'docs/L1_Contenu/cloudflare' } }], }, { label: 'L3 Backend', items: [{ autogenerate: { directory: 'docs/L3_Backend/cloudflare' } }], }, ], }, ], // Options globales (2Ăšme argument) { exclude: [ '/docs/*.pdf', '/404', '/', '/index', '/zen-mode/**', // routes injectĂ©es par starlight-view-modes '/presentation-mode/**', // routes injectĂ©es par starlight-view-modes ], } ), ],})4. Topics configurĂ©s dans ce projet
Section titled â4. Topics configurĂ©s dans ce projetâ| Label | Lien dâentrĂ©e | IcĂŽne | Badge |
|---|---|---|---|
| Vue dâensemble | /docs/ |
information |
â |
| Getting Started | /gettingstarted/01-setup-local/ |
rocket |
đ caution |
| Astro | /docs/l2_presentation/astro/... |
astro |
â |
| Cloudflare | /docs/l3_backend/cloudflare/... |
cloudflare |
â |
| Sanity | /docs/l1_contenu/sanity/... |
seti:db |
â |
| Pagefind | /docs/l2_presentation/pagefind/... |
magnifier |
â |
| Architecture & ADR | /docs/l2_presentation/adr/... |
open-book |
đ caution |
| Project Management | /docs/pm/... |
seti:plan |
đ caution |
| Standard Operating Procedure | /docs/sop/... |
approve-check-circle |
đ caution |
5. Badges sur les topics privés
Section titled â5. Badges sur les topics privĂ©sâLe badge est un objet { text: string, variant: string }. Les topics rĂ©servĂ©s aux collaborateurs (non accessibles sans authentification) reçoivent un badge cadenas :
badge: { text: 'đ', variant: 'caution' }Note : le plugin ne supporte pas dâicĂŽnes SVG dans le badge, uniquement du texte. Lâemoji đ est la meilleure approximation visuelle.
6. Conflit avec un override custom de Sidebar
Section titled â6. Conflit avec un override custom de Sidebarâstarlight-sidebar-topics override le composant Sidebar de Starlight. Si le projet override Ă©galement Sidebar (ex: pour ajouter un bloc auth), les deux overrides entrent en conflit.
Solution : importer overrides/Sidebar.astro du plugin
Section titled âSolution : importer overrides/Sidebar.astro du pluginâLe composant custom doit importer starlight-sidebar-topics/overrides/Sidebar.astro (qui inclut Topics + items) et non lâoriginal Starlight.
---// â
Correct : inclut topics + arborescence du topic actifimport Default from 'starlight-sidebar-topics/overrides/Sidebar.astro';
// â Mauvais : bypasse les topics// import Default from '@astrojs/starlight/components/Sidebar.astro';
// â Mauvais : topics seulement, pas les items// import Default from 'starlight-sidebar-topics/components/Sidebar.astro';---
<Default {...Astro.props}><slot /></Default><!-- Ă©lĂ©ments additionnels ici -->Voir SidebarWithAuth.astro pour lâimplĂ©mentation complĂšte.
7. Exclusions obligatoires
Section titled â7. Exclusions obligatoiresâTout plugin Starlight qui injecte de nouvelles routes (ex: starlight-view-modes) crĂ©e des pages que starlight-sidebar-topics ne reconnaĂźt pas. Ces routes doivent ĂȘtre dans exclude sous peine dâerreur au build :
AstroUserError: Failed to find the topic for the `zen-mode` page.8. Tests de validation
Section titled â8. Tests de validationâ- Les topics sâaffichent dans le sidebar (liste cliquable avec icĂŽnes)
- Cliquer sur un topic affiche son arborescence complĂšte
- Les badges đ apparaissent sur les 4 topics privĂ©s
- Naviguer sur une page affiche automatiquement le bon topic actif
- Les routes
/zen-mode/**et/presentation-mode/**ne causent pas dâerreur