Skip to content

Docs Site Setup

Each lexicon can include a documentation site built with Astro Starlight. The docs site lives in lexicons/<name>/docs/.

Create the docs directory structure:

Terminal window
mkdir -p lexicons/my-lexicon/docs/src/content/docs
// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
export default defineConfig({
base: '/chant/lexicons/my-lexicon/',
integrations: [
starlight({
title: 'My Lexicon',
sidebar: [
{ label: '← chant docs', link: '../../' },
{ label: 'Overview', slug: 'index' },
{ label: 'Getting Started', slug: 'getting-started' },
// ... add more pages
],
}),
],
});
{
"name": "@intentius/chant-lexicon-my-lexicon-docs",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview"
},
"dependencies": {
"@astrojs/starlight": "^0.37.6",
"astro": "^5.6.1",
"sharp": "^0.34.2"
}
}
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"]
}

A comprehensive docs site should have these pages (as MDX files in docs/src/content/docs/):

PageFileDescription
Overviewindex.mdxInstallation, quick start, feature list
Getting Startedgetting-started.mdxFirst project walkthrough
Resourcesresources.mdxResource types, resource-level fields
Intrinsicsintrinsics.mdxTemplate functions (if applicable)
Pseudo-Parameterspseudo-parameters.mdxDeployment-time parameters
Compositescomposites.mdxAll composites with examples
Parameters & Outputsparameters-outputs.mdxTemplate parameters and outputs
Lint Ruleslint-rules.mdxAll pre-synth and post-synth checks
Importingimporting.mdxImport existing templates
Advanced Patternslinked-templates.mdxAdvanced usage patterns
Examplesexamples.mdxWalkthrough of example projects
Terminal window
# Development server
cd lexicons/my-lexicon/docs
npm install
npm run dev
# Production build
npm run build

Add a docs script to your lexicon’s package.json:

{
"scripts": {
"docs": "npx tsx src/codegen/docs-cli.ts",
"docs:dev": "cd docs && npm run dev",
"docs:build": "cd docs && npm run build"
}
}

Each MDX page requires YAML frontmatter:

---
title: "Page Title"
description: "Brief description for SEO and sidebar"
---
Content goes here...

The 13 docs sites (main + 12 lexicons) build independently and stitch into a single tree at .docs-dist/chant/. Astro’s base: '/chant' only prefixes its own sidebar/slug entries — root-relative links written in MDX body content don’t get prefixed automatically.

A shared rehype-base-url plugin (packages/core/src/codegen/rehype-base-url.mjs) closes the gap: it walks the HAST tree and prepends the site’s base to <a href> values that start with /. The lexicon codegen wires this into every generated astro.config.mjs, so new lexicons get it for free.

Two gotchas:

  • Linking across namespaces from a lexicon page. A lexicon site’s base is /chant/lexicons/<name>, so [guide](/guide/composite-resources/) in lexicons/aws/... would get prefixed to /chant/lexicons/aws/guide/composite-resources/ (wrong). Write the full project path — /chant/guide/composite-resources/ — and the plugin’s idempotency check (projectBase: '/chant') leaves it alone.
  • Sibling pages in MDX. [foo](./foo) from aks-composites.mdx resolves to aks-composites/foo (child), not the sibling foo page. Use ../foo/ (or the absolute /chant/... form).

just docs-check-links runs lychee against the built .docs-dist/chant/ tree and catches both classes of breakage.

  • K8s docs: lexicons/k8s/docs/ — 11 pages with full sidebar navigation
  • Azure docs: lexicons/azure/docs/ — 11 pages covering ARM templates