@vited/core
v0.6.0
Published
Core Vite integration and documentation pipeline for Vited
Readme
@vited/core
Vited's core package integrates the documentation pipeline with Vite. It keeps Vite's configuration intact and adds document discovery, frontmatter parsing, Markdown/MDX transforms, and a virtual React entry point for the selected theme.
Configuration
import { defineConfig } from '@vited/core';
export default defineConfig({
docs: {
title: 'My Cool Library',
description: 'A short description of My Cool Library.',
keywords: ['library', 'example'],
supportedLocales: ['en', 'zh'],
theme: '@vited/theme-mantine',
},
});The HTML description and keywords use docs.description and docs.keywords
when provided, and otherwise use the matching fields from package.json.
During a production build, Vited emits an HTML shell for each documentation
page (guide/start becomes guide/start/index.html). Page frontmatter
title, description, and keywords override the corresponding HTML head
values. The page title is written as <page title> – <site title>, and themes
update the document title when readers navigate between pages. The page body
remains client-rendered; the generated HTML provides the page-specific head for
crawlers.
Production builds are written to docs_dist by default to avoid conflicts with
the project's own dist directory. A configured Vite build.outDir takes
precedence.
Vited reads documents from the docs directory under the Vite project root.
Vited discovers .md and .mdx files recursively; other files are not pages,
and React components (.jsx, .tsx) are imported from MDX documents. Directory
names form route segments and README.md is the directory index. A supported
locale suffix before the extension selects the locale, for example guide.zh.md.
The first configured locale uses the unprefixed route; other locales use a
/<locale>/ prefix, so README.zh.md is available at /zh/. Markdown
frontmatter is available as each page's frontmatter; its title becomes the
page title.
Vited compiles .md and .mdx files into React components with
@mdx-js/rollup. Themes can customize rendered Markdown elements through the
MDX components prop.
Themes render the pages themselves, so Vited resolves URLs before handing data
to the theme. Every page and route carries a pathname that a client router
matches (/zh/guide/start/) and a url with the site base URL
(/docs/zh/guide/start/). Page URLs are directory style and end with a slash.
routes lists every page route in every configured locale, including the page
that renders it and the translation it falls back to, so a theme can switch
language without building paths. routeIndex maps a pathname, with or without
the trailing slash, to its route, so a page is found for both URL forms. Menu
entries configured with path receive pathnames and urls per locale the
same way, and basePath is the site base URL without a trailing slash, for
client routers. Search results carry a pathname as well.
While the development server runs, editing a document refreshes the page component in place. Frontmatter changes, and added or removed documents, update the sidebar and search index without a full page reload.
Place favicon.svg or favicon.png in docs to use a project favicon. SVG is
preferred when both files exist. If neither file exists, Vited does not add a
favicon; any favicon already declared in the project's index.html is preserved.
Fenced code blocks in Markdown and MDX are syntax-highlighted by the selected
theme when a language is specified on the fence (for example, TypeScript or
JavaScript). The default Mantine theme uses Shiki with @mantine/code-highlight
and provides copy controls and light/dark color schemes.
Vited passes the project's package.json object to the theme as packageJSON.
The default Mantine theme uses its repository and funding fields for
optional GitHub and Donate links in the header.
The default Mantine theme also provides local document search. Vited builds a
search index from Markdown and MDX titles and text; results are scoped to the
selected locale. Open search with the Search button or Ctrl+K / ⌘K.
The development guide demonstrates nested pages and English/Chinese documentation.
Vited uses its built-in HTML shell when the project does not include an
index.html; if one exists, Vited uses that file. The built-in shell provides a
<body> element and a #root mount point for the selected React theme.
AI agents
The published package includes AGENTS.md, a concise setup and
configuration guide for AI agents working in projects that use @vited/core.
After installing the package, agents can read it at
node_modules/@vited/core/AGENTS.md.
Development
pnpm install
pnpm dev
pnpm test
pnpm build