# From Mintlify

Move a Mintlify site to Vuesho.

`@vuesho/mintlify` runs a Mintlify project on Vuesho. It applies the navigation, colors, redirects and analytics from your `docs.json` to the site, and its CLI converts `.mdx` pages to Markdown with Vue syntax.

## Setup [#setup]

### Create a Site [#create-a-site-step]

Create a site as in [Getting Started](/), then install the package:

```npm
npm i @vuesho/mintlify @lucide/vue
```

### Move the Project Files [#move-the-project-files-step]

Keep `docs.json`, the files its `$ref` keys point to, and `snippets/` at the root. Move the pages into `content/`, and the assets that pages link with root paths, like `/images/a.png`, into `public/`:

```files
my-docs
├── content
│   ├── index.mdx
│   └── quickstart.mdx
├── public
│   └── logo.svg
├── snippets
│   └── install.mdx
├── docs.json
└── vuesho.config.ts
```

Page paths in `navigation` resolve inside `content/`, without a leading `docs/` or `content/docs/`.

### Convert the Pages [#convert-the-pages-step]

The command rewrites the `.mdx` files in `content/` and `snippets/` as `.md` files with Vue syntax:

```bash
npx vuesho-mintlify convert
```

```md tab="quickstart.mdx"
---
title: Quickstart
---

import Install from "/snippets/install.mdx";

export const version = "24";

{/* Shown on every page */}

<Note>Requires Node.js {version} or later.</Note>

<Install />
```

```md tab="quickstart.md"
---
title: Quickstart
---

<!-- Shown on every page -->

<Note>Requires Node.js {{ version }} or later.</Note>

<include cwd>snippets/install.md</include>

<script>
export const version = "24";
</script>
```

A snippet becomes an [include](/markdown#includes), and its attributes become [props](/markdown#props) of the snippet. It reports the file and line of each part it can't convert, like JSX inside an expression or a `.jsx` component.

### Fix the Remaining Syntax [#fix-the-remaining-syntax-step]

Change three patterns by hand:

- Replace `<CodeGroup>` with [code tabs](/markdown#code-tabs).
- Move a `<Card>`'s `icon` into its `#icon` slot.
- Write frontmatter icons as [Lucide names](/navigation#icon-names), like `BookOpen` for `book-open`.

````md tab="Converted"
---
title: Introduction
icon: book-open
---

<Card title="Quickstart" icon="rocket" href="/quickstart">
  Get going in five minutes.
</Card>

<CodeGroup>

```bash npm
npm i acme
```

```bash pnpm
pnpm add acme
```

</CodeGroup>
````

````md tab="Updated"
---
title: Introduction
icon: BookOpen
---

<Card title="Quickstart" href="/quickstart">
  <template #icon><Rocket /></template>
  Get going in five minutes.
</Card>

```bash tab="npm"
npm i acme
```

```bash tab="pnpm"
pnpm add acme
```

<script setup>
import { Rocket } from "@lucide/vue";
</script>
````

<Callout title="Type Checking">
For [type checking](/markdown/type-checking), map `/snippets/*` in `tsconfig.json`:

```json title="tsconfig.json"
{
  "compilerOptions": {
    "paths": { "/snippets/*": ["./snippets/*"] }
  },
  "include": ["*.ts", "src", "content", "snippets"]
}
```
</Callout>

### Map the Components [#map-the-components-step]

Define Mintlify's components in a module, and register them with a plugin's `components`. Each key maps to the named export of that module. Write the components this example leaves out, like `Frame` or `ParamField`, yourself.

```ts title="src/mintlify.ts"
import { defineComponent, type FunctionalComponent, h } from "vue";
import {
  Accordions,
  Callout,
  Cards,
  Step as VueshoStep,
  Tab as VueshoTab,
  Tabs as VueshoTabs,
} from "vuesho/components";

type CalloutType = "info" | "idea" | "warn" | "error" | "success";

const callout =
  (type: CalloutType): FunctionalComponent =>
  (_, { slots }) =>
    h(Callout, { type }, slots);

export const Note = callout("info");
export const Info = callout("info");
export const Tip = callout("idea");
export const Warning = callout("warn");
export const Danger = callout("error");
export const Check = callout("success");

export const AccordionGroup = Accordions;

export const CardGroup = defineComponent({
  props: { cols: Number },
  setup(props, { slots }) {
    return () => {
      const columns = props.cols && `repeat(${props.cols}, minmax(0, 1fr))`;
      return h(Cards, { style: { gridTemplateColumns: columns } }, slots);
    };
  },
});
export const Columns = CardGroup;

// Mintlify names each tab via the `title` prop on `Tab`.
export const Tabs = defineComponent((_, { slots }) => () => {
  const tabs = slots.default?.() ?? [];
  const items = tabs.flatMap((tab) => tab.props?.title ?? []);
  return h(VueshoTabs, { items }, () => tabs);
});

export const Tab = defineComponent({
  props: { title: { type: String, required: true } },
  setup(props, { slots }) {
    return () => h(VueshoTab, { value: props.title }, slots);
  },
});

export const Step = defineComponent({
  props: { title: String },
  setup(props, { slots }) {
    const title = () => props.title && h("h3", props.title);
    return () => h(VueshoStep, null, () => [title(), slots.default?.()]);
  },
});
```

`Tabs`, `Tab` and `Step` replace the built-in components, so every page uses Mintlify's props for them.

### Add the Plugin [#add-the-plugin-step]

Add `mintlify.plugin()`, and a plugin whose `components` maps each name to `src/mintlify.ts`:

```ts title="vuesho.config.ts"
import { createMintlify } from "@vuesho/mintlify"; // [!code ++]
// ...

const mintlify = createMintlify(); // [!code ++]
const m = "/src/mintlify.ts"; // [!code ++]

export default createSite(docs.toSource()).plugins(
  recommendedPreset(),
  lucideIconsPlugin(),
  ogImagePlugin(),
  mintlify.plugin(), // [!code ++]
  // [!code ++:4]
  {
    name: "site:mintlify",
    components: {
      Note: m,
      Info: m,
      Tip: m,
      Warning: m,
      Danger: m,
      Check: m,
      AccordionGroup: m,
      CardGroup: m,
      Columns: m,
      Tabs: m,
      Tab: m,
      Step: m,
    },
  },
);
```

Vuesho reads `docs.json` when the site builds, and your own config overrides it.

## Customization [#customization]

### Turning Off Features [#turning-off-features]

To configure a part of `docs.json` in Vuesho instead, turn it off in `features`:

```ts title="vuesho.config.ts"
mintlify.plugin({ features: { search: false } });
```

### CreateMintlifyOptions

| Prop               | Type                                  | Description                                                                                                    |
| ------------------ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `path?`            | `string \| undefined`                 | The path of `docs.json`, from `root`. Default: `"docs.json"`                                                   |
| `root?`            | `string \| undefined`                 | The project folder, which every `$ref` in `docs.json` must stay inside. Default: `the folder the site runs in` |
| `localeMap?`       | `Record<string, string> \| undefined` | The site language for each `docs.json` language, by Mintlify code, like `{ cn: "zh" }`.                        |
| `defaultLanguage?` | `string \| undefined`                 | The default language's Mintlify code, instead of the one `docs.json` marks `default`, or else its first.       |

### MintlifyPluginOptions

| Prop        | Type                            | Description                                                                                                                                 |
| ----------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `docsDir?`  | `string \| undefined`           | The page tree folder that holds the Mintlify project's pages, where the paths in `navigation` start. Default: `"", the root of the content` |
| `features?` | `MintlifyFeatures \| undefined` | The parts of `docs.json` the plugin applies. Each is on unless set to `false`, which leaves it to the site.                                 |

### MintlifyFeatures

| Prop          | Type                   | Description                                                                                                                                            |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `navigation?` | `boolean \| undefined` | The sidebar, from `navigation`.                                                                                                                        |
| `navbar?`     | `boolean \| undefined` | The navbar's links and button, and its title from `name` and `logo`.                                                                                   |
| `head?`       | `boolean \| undefined` | Every page's head: `colors`, `background`, `fonts`, `favicon`, `description`, `seo` and `integrations`, and `noindex` on pages outside the navigation. |
| `appearance?` | `boolean \| undefined` | The color mode, from `appearance`.                                                                                                                     |
| `banner?`     | `boolean \| undefined` | The announcement from `banner`.                                                                                                                        |
| `footer?`     | `boolean \| undefined` | The links and social accounts from `footer`.                                                                                                           |
| `redirects?`  | `boolean \| undefined` | The `redirects`, as Nitro route rules where possible, and on the server otherwise.                                                                     |
| `notFound?`   | `boolean \| undefined` | The not found page from `errors.404`.                                                                                                                  |
| `search?`     | `boolean \| undefined` | The search placeholder, from `search.prompt`.                                                                                                          |
| `metadata?`   | `boolean \| undefined` | A page's last update date, shown only with `metadata.timestamp`.                                                                                       |

### Not Found Page [#not-found-page]

`errors.404` redirects to `/` by default. With `redirect: false`, the site renders a not found page from the `title` and `description` of `errors.404`, or its own not found page when both are missing. To replace that page, set the `mintlify.404` [view](/theme#views-and-page-bodies) in `src/theme.ts`:

```ts title="src/theme.ts"
import { defineTheme } from "vuesho/theme";
import defaultTheme from "vuesho/theme/default";

export default defineTheme({
  extends: defaultTheme,
  views: { "mintlify.404": () => import("./NotFound.vue") },
});
```

### Languages [#languages]

`createMintlify()` builds the [i18n config](/i18n) from `navigation.languages`. Pass `localeMap` to rename language codes:

```ts title="vuesho.config.ts"
const mintlify = createMintlify({ localeMap: { cn: "zh" } }); // [!code highlight]

export default createSite(docs.toSource(), { i18n: mintlify.i18n }) // [!code highlight]
  .plugins(
    recommendedPreset(),
    // ...
    mintlify.plugin(),
  )
  .config({ site: { languages: mintlify.languages } }); // [!code highlight]
```

Without `navigation.languages`, `i18n` and `languages` are `undefined`. Each language uses the navigation, navbar, banner and footer that `docs.json` sets for it, or the top-level ones.

### API Pages [#api-pages]

`createMintlifyOpenAPI()` and `createMintlifyAsyncAPI()` read `api.openapi` and `api.asyncapi` from `docs.json`, for [OpenAPI](/api-docs/openapi) and [AsyncAPI](/api-docs/asyncapi):

```ts tab="OpenAPI" title="vuesho.config.ts"
import { createMintlifyOpenAPI } from "@vuesho/mintlify/openapi";
import { openapiPlugin } from "@vuesho/openapi";
// ...

const { openapi, proxy } = createMintlifyOpenAPI();

export default createSite({
  docs: docs.toSource(),
  api: openapi.staticSource({ baseDir: "api" }), // [!code highlight]
}).plugins(
  recommendedPreset(),
  // ...
  mintlify.plugin(),
  openapiPlugin({ proxy }), // [!code highlight]
);
```

```ts tab="AsyncAPI" title="vuesho.config.ts"
import { asyncapiPlugin } from "@vuesho/asyncapi";
import { createMintlifyAsyncAPI } from "@vuesho/mintlify/asyncapi";
// ...

const asyncapi = createMintlifyAsyncAPI();

export default createSite({
  docs: docs.toSource(),
  events: asyncapi.staticSource({ baseDir: "events" }), // [!code highlight]
}).plugins(
  recommendedPreset(),
  // ...
  mintlify.plugin(),
  asyncapiPlugin(), // [!code highlight]
);
```

Both helpers give the built server their `docs.json` and its `$ref` files, so the site needs no extra `serverFiles` for them. They work without `createMintlify().plugin()` and with another `path`.

Both take the same options as `createOpenAPI()` and `createAsyncAPI()`, and fail when neither `docs.json` nor `input` lists an API document. For a static build, turn off the playground proxy with `api.playground.proxy: false`.

## Supported `docs.json` Keys [#supported-docsjson-keys]

The plugin applies these keys, and ignores the others:

| Key                                    | Result                                                                                         |
| -------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `name`                                 | The navbar title, when there's no logo                                                         |
| `description`                          | The page description, unless `site.description` is set                                         |
| `colors.primary`, `colors.light`       | The accent color in light and dark mode                                                        |
| `logo`, `favicon`                      | One image, or one per color mode, and `logo.href`                                              |
| `navigation`                           | The sidebar, see [Navigation Keys](#navigation-keys)                                           |
| `navbar`                               | Navbar links and a button                                                                      |
| `appearance`                           | The default color mode, and no color mode switch with `strict`                                 |
| `background.color`, `background.image` | The page background in each color mode                                                         |
| `fonts`                                | Google Fonts, weights 400 to 700 by default, or local `.woff` and `.woff2` files with `source` |
| `banner`                               | A Markdown banner, with `dismissible`, `type` and `color`                                      |
| `footer`                               | Social links with icons, and columns of links                                                  |
| `redirects`                            | Permanent and temporary redirects, by path or pattern                                          |
| `errors.404`                           | A redirect home, or a not found page with a title and description                              |
| `seo.metatags`, `seo.indexing`         | Meta tags on every page, and `noindex` on unlisted pages with `navigable`                      |
| `search.prompt`                        | The search placeholder                                                                         |
| `metadata.timestamp`                   | The [last modified date](/markdown/collections#last-modified-dates), with `true`               |
| `integrations`                         | Analytics scripts                                                                              |
| `api.openapi`, `api.asyncapi`          | API reference pages, with the helpers above                                                    |

<Accordions>
<Accordion title="Supported analytics integrations">
`integrations` adds the scripts for Amplitude, Clarity, Fathom, Google Analytics 4, Google Tag Manager, Heap, Hotjar, Intercom, Koala, LogRocket, Mixpanel, Pirsch, Plausible, PostHog and Segment. Add others with [head tags](/seo#head-tags).
</Accordion>
</Accordions>

<Callout title="Redirects on Static Hosts">
A redirect of an exact path, or of a whole folder with `*`, works on a static build: Vercel, Netlify and Cloudflare
apply it, and for another static host the build writes a page for each exact path. Other patterns, like `:slug`, and
a redirect that overlaps another need a server.
</Callout>

### Navigation Keys [#navigation-keys]

| `navigation` key                                   | Sidebar                                                                               |
| -------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `pages`                                            | Pages, in order                                                                       |
| `groups`                                           | Folders, open with `expanded: true` and linked with `root`                            |
| `tabs`, `anchors`, `dropdowns`, `products`, `menu` | Top-level folders, or external links with `href`                                      |
| `versions`                                         | A root folder for each version                                                        |
| `languages`                                        | A sidebar for each language, see [Languages](#languages)                              |
| `global`                                           | Tabs, anchors, dropdowns and products added before those of each version and language |

Groups and versions take a `tag`, shown as a badge in the sidebar. Groups, tabs, anchors, dropdowns, products and menus take an `icon`, and every item except a page takes `hidden`.

## Icons [#icons]

Icons render with [Lucide](https://lucide.dev). Common Font Awesome and Tabler names map to Lucide icons, and Vuesho warns about an unknown name.
