How it works
The content model, the markdown pipeline, and navigation.
Markdown as routes
DocSmith leans on mdsvex, which compiles markdown into real Svelte components. A file becomes a page by its position on disk, with no loader and no catch-all route:
- src
- routes
- docs
- guides
- routing
- +page.md
- routing
- guides
- docs
- routes
The file above serves /docs/guides/routing. Because it is a normal SvelteKit
route, you can drop interactive Svelte components straight into the markdown and
they run as part of the same app.
One plugin, one config
Everything DocSmith does at build time comes from one docsmith() call in vite.config.ts, from svelte-docsmith/vite:
- It compiles each
.mdfile into a styled, highlighted page (mdsvex, Shiki, heading anchors, the page layout) before SvelteKit compiles it like any component. - It generates the content index (below), the search and llms indexes, and
the
?sourceand?propsimports that power live examples and props tables. - It serves your site config as
svelte-docsmith/site, whereDocsShell,ErrorPageand the route handlers read it.
So each setting has one home. The themes you pick colour markdown fences and live example source alike, and the changelog route the feed links to is the one the changelog is served at.
Nav is derived, never written
There is no navigation array to maintain. The docsmith() Vite plugin reads
each page’s frontmatter into the svelte-docsmith/content module, and DocsShell groups the entries into the sidebar:
section names the group; order sorts entries within it; groups are ordered
by the smallest order they contain. Add a page, and it slots into the sidebar
in the right place automatically.
Two tables of contents, two jobs
DocSmith keeps two structures, and they never overlap:
- The content index owns build-time structure. The
docsmith()Vite plugin scans frontmatter into the sidebar navigation. - The runtime TOC engine owns in-page scroll tracking. It scans the rendered headings and highlights the section you are reading.
The highlighting pipeline
Code blocks are highlighted by Shiki when docsmith() compiles the page, with a generous default language set. Unknown
languages fall back to plain text instead of failing the build:
Highlighting is dual-theme: the same markup carries light and dark colors and flips with the page theme, so your code reads correctly either way.