# Config Reference

Options for vuesho.config.ts.

[`vuesho.config.ts`](/#config-file) exports a site, created in three calls:

```ts title="vuesho.config.ts"
import { createSite, recommendedPreset } from "vuesho/config";
import { defineDocs } from "vuesho/content";

const docs = defineDocs();

export default createSite(docs.toSource(), {
  // The content options: languages, slugs, icons, the page tree.
})
  .plugins(recommendedPreset())
  .config({
    site: { name: "Acme Docs", baseUrl: "https://docs.acme.dev" },
    head: [],
    ui: { layoutProps: {}, colorMode: {} },
    markdown: {},
  });
```

## `createSite()` [#createsite]

The first argument is the content: one [source](/content-sources), or an object of sources by key, like `{ docs: docs.toSource(), blog: blog.toSource() }`. The second argument holds the content options, for every source:

### ContentOptions

| Prop         | Type                                                                                                                                                               | Description                                                                |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| `baseSlugs?` | `string[] \| undefined`                                                                                                                                            | Slugs before every page's slugs.                                           |
| `slugs?`     | `((file: Omit<Page<undefined, never>, "url" \| "locale"> & { format: "page"; }, next: () => string[]) => string[] \| undefined) \| undefined`                      | A page's slugs, or none for the slugs from its path, which `next()` gives. |
| `url?`       | `((slugs: string[], locale?: string) => string) \| undefined`                                                                                                      | A page's URL from its slugs and language.                                  |
| `icon?`      | `((icon: string \| undefined) => Renderable \| undefined) \| undefined`                                                                                            | Turns a file's `icon` into its node's icon.                                |
| `pageTree?`  | `(Partial<PageTreeOptions> & { transformers?: PageTreeTransformer<ContentStorage<Page<undefined, never>, Meta<undefined, never>>>[] \| undefined; }) \| undefined` | Options and transformers for building the page tree.                       |
| `i18n?`      | `I18nConfig<string> \| undefined`                                                                                                                                  | The site's languages, each with its pages, page tree and URLs.             |

## `.plugins()` [#plugins]

`.plugins()` takes your plugins, in order. It flattens arrays, skips `false`, `null` and `undefined`, and calls a function with the site's sources, so a plugin can read them at start:

```ts title="vuesho.config.ts"
createSite(docs.toSource()).plugins(
  recommendedPreset(),
  process.env.ANALYTICS === "1" && analyticsPlugin(),
);
```

[Plugin API](/plugin-api) covers writing a plugin.

## `.config()` [#config]

### `site` [#site]

### SiteConfig

| Prop           | Type                                                                                                                                        | Description                                                                                                                                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name?`        | `string \| undefined`                                                                                                                       | Shown in the navbar and in page titles.                                                                                                                                                                                                   |
| `logo?`        | `string \| undefined`                                                                                                                       | An image shown before the name in the navbar, like `/logo.svg` of `public/`.                                                                                                                                                              |
| `description?` | `string \| undefined`                                                                                                                       |                                                                                                                                                                                                                                           |
| `lang?`        | `string \| undefined`                                                                                                                       | The language tag, for `<html lang>`, `hreflang` and the text direction. Default: `"en"`                                                                                                                                                   |
| `languages?`   | `({ [x: string]: LanguageConfig \| undefined; } & { [key: string]: LanguageConfig \| undefined; }) \| undefined`                            | The site in each `i18n` language, by key, like `{ cn: { lang: "zh-CN", label: "中文" } }`. Another key is an external language, on another site, which the language switch lists with its `label` and `link`, on a site without `i18n` too. |
| `baseUrl?`     | `string \| undefined`                                                                                                                       | The deployed site's origin, like `https://docs.example.com`, for canonical links.                                                                                                                                                         |
| `git?`         | `{ provider?: "github" \| "gitlab" \| "bitbucket"; url?: string; user: string; repo: string; branch?: string; dir?: string; } \| undefined` | The site's repository, which the navbar and each page's `githubUrl` link to.                                                                                                                                                              |

`site.baseUrl` is your deployed site's origin, without a base path. The sitemap, the RSS feed, canonical links and Open Graph images need it, as [SEO](/seo#site-url) shows. `site.languages` names each language on a site with [i18n](/i18n#name-the-languages-step).

### `head` [#head]

[Head tags](/seo#head-tags) for every page, or a function that returns a page's tags.

### `ui` [#ui]

```ts title="vuesho.config.ts"
createSite(docs.toSource()).config({
  ui: {
    // The navbar, its links and the sidebar tabs of every layout.
    layoutProps: { nav: { title: "Acme" } },
    // The color mode before the reader picks one.
    colorMode: { default: "dark" },
    // The UI's texts, over its language packs.
    translations: { "On this page(table of contents)": "Contents" },
  },
});
```

Each option has a guide:

- `layoutProps`: [Navigation](/navigation)
- `colorMode`: [Color Mode](/styling#color-mode)
- `translations`: [UI Translations](/i18n#ui-translations)

### LayoutProps

| Prop               | Type                                                                                                            | Description                                                                                 |
| ------------------ | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `nav?`             | `NavOptions \| undefined`                                                                                       | The navbar.                                                                                 |
| `links?`           | `LinkItem[] \| undefined`                                                                                       | The navbar's links.                                                                         |
| `githubUrl?`       | `string \| undefined`                                                                                           | The repository URL, which the navbar links to. Default: ``the one of `site.git` on GitHub`` |
| `colorModeSwitch?` | `{ enabled?: boolean; mode?: "light-dark" \| "light-dark-system"; } \| undefined`                               | The color mode switch, which a `fixed` color mode hides.                                    |
| `searchToggle?`    | `{ enabled?: boolean; sm?: { hideIfDisabled?: boolean; }; full?: { hideIfDisabled?: boolean; }; } \| undefined` | Whether the layout shows the search trigger buttons.                                        |
| `tabs?`            | `false \| AsJson<Omit<LayoutTab, "props" \| "$folder" \| "urls">>[] \| undefined`                               | The sidebar's tabs, or `false` for none. Default: `the root folders of the page tree`       |

### ColorModeOptions

| Prop         | Type                               | Description                                                                                      |
| ------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------ |
| `default?`   | `ColorModePreference \| undefined` | The color mode until the reader picks one. The color mode of every page. Default: `"system"`     |
| `fixed?`     | `boolean \| undefined`             | Stops the reader from picking: the layouts have no switch, and a stored pick is ignored.         |
| `hotKey?`    | `string \| false \| undefined`     | The key that toggles light and dark when pressed alone, or `false` for none. Default: `"d"`      |
| `attribute?` | `ColorModeAttribute \| undefined`  | Where the color mode applies on `<html>`: its class, or a `data-*` attribute. Default: `"class"` |

### `markdown` [#markdown]

How pages compile. A [collection](/markdown/collections#markdown-options) can override these options.

### MarkdownOptions

| Prop                 | Type                                     | Description                                                                                                                                                                                                                                 |
| -------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `markdownItPlugins?` | `MarkdownItPlugin[] \| undefined`        | markdown-it plugins, which add syntax. The tokens they create render as their renderer's HTML.                                                                                                                                              |
| `highlight?`         | `HighlightOptions \| undefined`          | The built-in highlighter's code themes, or `highlighter` to create another one. `transformers` apply to both.                                                                                                                               |
| `imageSize?`         | `false \| ImageSizeOptions \| undefined` | Reads image widths and heights in the build, so images take up their space before they load. Default: `{}`                                                                                                                                  |
| `imagePlaceholder?`  | `"blur" \| undefined`                    | `"blur"` gives each image file of a page the build compiles, next to the page or in `public`, a blurred copy that shows until it loads, like `placeholder: "blur"` in `next/image`. The build makes it with sharp, which the site installs. |
| `slug?`              | `string \| undefined`                    | A module whose default export gives a heading's ID from its text, as a path from the project root, like `"src/slug.ts"`. Default: `GitHub's slugger`                                                                                        |

The `slug` module exports a function that returns a heading's ID from its text:

```ts tab="vuesho.config.ts"
createSite(docs.toSource()).config({
  markdown: { slug: "src/slug.ts" },
});
```

```ts tab="src/slug.ts"
export default (text: string) => text.trim().toLowerCase().replaceAll(" ", "_");
```

## `recommendedPreset()` [#recommendedpreset]

`recommendedPreset()` returns the plugins that most sites want. Each key turns its plugin off with `false`, and most keys also take that plugin's options:

```ts title="vuesho.config.ts"
createSite(docs.toSource()).plugins(
  recommendedPreset({
    // Each plugin is on by default: `false` turns it off, and an object passes its options.
    codeTabs: false, // Code blocks with `tab` become tabs
    npm: {}, // `npm` code blocks become a tab per package manager
    search: {}, // Search with MiniSearch
    sitemap: {}, // sitemap.xml, with `site.baseUrl`
    robots: {}, // robots.txt
    rss: {}, // An RSS feed, with `site.baseUrl`
    llms: {}, // llms.txt and each page's Markdown
    linkValidation: {}, // Fails the build on a dead link
    image: false, // Vercel's and Netlify's image optimizers
  }),
);
```

To [replace one of the preset's plugins](/plugins#replacing-a-plugin), turn it off with the preset's option and add the other plugin.

### RecommendedPresetOptions

| Prop              | Type                                                      | Description                                                                                                                                                                             |
| ----------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `codeTabs?`       | `false \| undefined`                                      | Groups code blocks with a `tab` into tabs.                                                                                                                                              |
| `npm?`            | `false \| NpmOptions \| undefined`                        | Turns an `npm` code block into tabs with the command for each package manager.                                                                                                          |
| `sitemap?`        | `false \| SitemapOptions<AppShape> \| undefined`          | Serves a `/sitemap.xml` of the pages, which needs `site.baseUrl`.                                                                                                                       |
| `robots?`         | `false \| RobotsOptions \| undefined`                     | Serves `/robots.txt`, which names the sitemap.                                                                                                                                          |
| `llms?`           | `false \| LLMsOptions<AppShape> \| undefined`             | Serves `llms.txt`, `llms-full.txt` and each page's Markdown at `<page>.md`.                                                                                                             |
| `rss?`            | `false \| RSSOptions<AppShape> \| undefined`              | Serves an RSS feed of the pages, which needs `site.baseUrl`.                                                                                                                            |
| `search?`         | `false \| MiniSearchPluginOptions<AppShape> \| undefined` | The options for `minisearchPlugin()`. Set it to `false` to list another engine's plugin instead.                                                                                        |
| `linkValidation?` | `false \| LinkValidationOptions<AppShape> \| undefined`   | Checks the links in generated pages, and fails the build on a dead link.                                                                                                                |
| `image?`          | `false \| undefined`                                      | The Vercel and Netlify image optimizers, each of which optimizes the site's images when the site deploys to its platform. Set it to `false` to list an optimizer with options, or none. |

## Vite Plugin [#vite-plugin]

`vite.config.ts` is optional. Write one to pass options to the Vuesho plugin, add other Vite plugins, or set [Nitro options](https://nitro.build/config) under `nitro`:

```ts title="vite.config.ts"
import { defineConfig } from "vite";
import vuesho from "vuesho/vite";

export default defineConfig({
  plugins: [vuesho({ trailingSlash: true })],
  nitro: { preset: "vercel" },
});
```

With this file, `vite dev`, `vite build` and `vite preview` work like the [CLI](/cli).

### VueshoOptions

| Prop             | Type                   | Description                                                                                     |
| ---------------- | ---------------------- | ----------------------------------------------------------------------------------------------- |
| `theme?`         | `string \| undefined`  | The site's theme module. Default: `"src/theme.ts" or "src/theme.js" when it exists`             |
| `trailingSlash?` | `boolean \| undefined` | Ends URLs without a file extension with `/`, for hosts that only serve a folder's `index.html`. |
| `vue?`           | `Options \| undefined` | Options for `@vitejs/plugin-vue`, added to those Vuesho sets.                                   |
