Build a docs site
Build a docs site
Leadtype offers two integration shapes for a docs site. Pick the one that fits how your app is built — both produce the same content, just at different layers of your stack.
Pick your path
| Path | When to choose | What you wire |
|---|---|---|
| Source primitive | Most cases. You're building a Next, Vite, Astro, or Fumadocs app and compile MDX with your bundler. | createDocsSource() (or leadtype/fumadocs) + createMdxSourcePlugins() |
| Static artifacts | Your runtime needs flat files on disk (CDN-only deploy, static export, agent-only consumption, multi-app sharing). | leadtype generate CLI in your build script |
The two paths are not mutually exclusive — you can use the source primitive for your UI and still run leadtype generate for the llms.txt and agent-readability artifacts.
Source primitive: the common path
If your docs app compiles MDX through a bundler, use the source primitive. It gives your runtime:
loadPage(slug)returning frontmatter + AST + serialized markdown + TOCgetNavigation()returning the resolved group treebuildSearchIndex()returning a static search indexresolveInclude()for programmatic partial loading
→ Use the source primitive — generic recipe → Integrate with Fumadocs — first-party adapter
Static artifacts: the CLI path
If your runtime needs files on disk — for a CDN-only deploy, a static export, a separate agent-only service, or to share artifacts across multiple sibling apps — run the CLI. It writes:
public/llms.txtandpublic/llms-full.txtpublic/docs/*.md(markdown mirrors)public/docs/search-index.json+search-content.jsonpublic/docs/sitemap.xml,sitemap.md,robots.txt,agent-readability.json
→ Generate static artifacts — CLI workflow
Add the cross-cutting features
Whichever path you pick, the same follow-on guides apply:
- Add search — local search index + optional source-grounded answers
- Optimize docs for agents — markdown responses, llms.txt, discovery files
- Validate in CI — lint frontmatter, meta.json, internal links
Configure product and groups
Both paths read the same docs/docs.config.ts. Source repos own this file so groups and product metadata version with the docs:
Pages declare group: in frontmatter; the config declares titles, order, and descriptions. See Frontmatter for the page-level schema.