Build with Vite
import { defineConfig } from 'vite'
import { docs } from '@memomori/charon/docs/vite'
export default defineConfig({
plugins: [docs({ siteUrl: 'https://acme.dev' })],
})
That is a whole site in charon's default theme, served at /docs from the
docs/ folder. It needs no HTML file per page: each page is a Vite entry made
from its Markdown, so your other plugins' transformIndexHtml hooks run on it.
In dev it re-renders when a page, an asset or the template changes.
Options #
| Option | Default | Means |
|---|---|---|
dir |
docs |
content folder, from the Vite root |
route |
/<dir> |
where the site is served; / for the whole site |
template |
charon's own | path of the page template, from the Vite root |
assets |
public/<dir>/assets |
images and notes that pages embed |
sections |
one per folder | sidebar groups; their order sets previous and next |
siteUrl |
origin for canonical URLs and the sitemap | |
name |
Docs |
heading of llms.txt and label on the social cards |
links |
{} |
link prefixes to swap, such as { 'app:/': '…' } |
diagrams |
diagram settings, such as { fontFamily } |
|
og |
turns on social cards | |
lang |
en |
{{lang}} and the date format |
labels |
English | the words around each page; see Labels |
contents |
{ minHeadings: 3 } |
how many h2s a page needs for "On this page" |
fences |
custom fence renderers |
These match the keys of charon.json; see Build a docs site.
Unlike the CLI, the plugin reads no charon.json.
Your own page #
Pass a template to wrap each page in your own HTML, then bring the styles
and script yourself:
docs({ template: 'docs-template.html' })
@import '@memomori/charon/styles.css';
@import '@memomori/charon/heading-links.css';
@import '@memomori/charon/examples.css';
@import '@memomori/charon/assets.css';
@import '@memomori/charon/docs.css';
import { startDocs } from '@memomori/charon/docs/client'
startDocs()
Template lists the placeholders, and Client
what startDocs does.
Custom fences #
docs({
fences: {
chart: (block) =>
`<div class="chart" data-spec="${btoa(block.value)}"></div>`,
},
})
The plugin renders every page, example and embed with your fences. See Custom fences.