# Build with Vite

```ts
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](social-cards.md)            |
| `lang`     | `en`                  | `{{lang}}` and the date format                      |
| `labels`   | English               | the words around each page; see [Labels](labels.md) |
| `contents` | `{ minHeadings: 3 }`  | how many `h2`s a page needs for "On this page"      |
| `fences`   |                       | [custom fence renderers](../fences.md)              |

These match the keys of `charon.json`; see [Build a docs site](index.md).
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:

```ts
docs({ template: 'docs-template.html' })
```

```css
@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';
```

```ts
import { startDocs } from '@memomori/charon/docs/client'

startDocs()
```

[Template](template.md) lists the placeholders, and [Client](search.md#client)
what `startDocs` does.

## Custom fences

```ts
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](../fences.md).
