src/content/docs is a symlink to ../../docs. Starlight expects content in src/content/docs/, providing a consistent structure for documentation.
We use a custom remark plugin (src/plugins/remark-mkdocs-snippets.ts) to include TypeScript code in markdown docs. This keeps code examples type-checked and in sync with actual source files.
Syntax in markdown:
--8<-- "user-guide/concepts/agents/hooks.ts:basic_example"Source file markers:
// --8<-- [start:basic_example]
const agent = new Agent({ tools: [myTool] })
// --8<-- [end:basic_example]The plugin extracts the section between markers, dedents it, and inlines it into the code block. Paths resolve from src/content/docs/.
Files: src/plugins/remark-mkdocs-snippets.ts, astro.config.mjs (registers plugin)
Starlight doesn't support Mermaid diagrams out of the box. We add client-side rendering via a component override.
How it works:
- Override Starlight's
Headcomponent (src/components/Head.astro) - Script finds
<pre data-language="mermaid">blocks on page load - Transforms them into
<pre class="mermaid">elements - Mermaid.js (loaded from CDN) renders them as SVGs
Why client-side? Simpler than build-time rendering (no Puppeteer), and can match Starlight's dark/light theme.
Files: src/components/Head.astro, astro.config.mjs (registers override)