Skip to content

Table of Contents

Starlight already has this feature, so no additional work is required. However, you can override the default one ↗.

See:

Check out the source code to see how to implement it:

  • Fix “snake” styles.
  1. Create TableOfContents component

    src/components/TableOfContents.astro
    ---
    import TOC from "./TOC.astro";
    ---
    <TOC {...Astro.props} />
  2. Configure Astro

    astro.config.mjs
    export default defineConfig({
    integrations: [
    starlight({
    components: {
    TableOfContents: "./src/components/TableOfContents.astro",
    },
    }),
    ],
    });