# Build with Vite

```ts
import { defineConfig } from 'vite'
import { docs } from '@memomori-app/elysium/vite'

export default defineConfig({
  plugins: [docs({ siteUrl: 'https://acme.dev' })],
})
```

That is a whole site in Elysium'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 a 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` | `<dir>/_templates`, if there, else Elysium's own | a page template, or a [folder](template.md#a-template-per-page) pages pick from, from the Vite root |
| `assets`   | `<dir>/_assets`                                  | images and notes that pages embed, from the Vite root                                               |
| `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)                                                            |
| `icon`     |                                                  | URL of the favicon                                                                                  |
| `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](https://charon.memomori.app/docs/fences)                                   |

These match the keys of `elysium.json`; see [Build a docs site](build.md).
Unlike the CLI, the plugin reads no `elysium.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-app/charon/styles.css';
@import '@memomori-app/charon/heading-links.css';
@import '@memomori-app/charon/examples.css';
@import '@memomori-app/charon/assets.css';
@import '@memomori-app/elysium/docs.css';
```

```ts
import { startDocs } from '@memomori-app/elysium/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](https://charon.memomori.app/docs/fences).
