ViteReact文档

mosona-docs — Vite 文档模板

作者 mosona-labs

基于 React、Vite 和 Tailwind CSS 4 的文档站点模板,将 Markdown 内容构建为支持多语言、侧边栏导航、页面目录、代码高亮和 Pagefind 全文搜索的静态站点。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-18查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

基于 React + Vite + Tailwind CSS 4 构建,输出静态 SPA

02

使用 Markdown 编写文档,支持 GFM 表格、任务列表和原始 HTML

03

多语言支持:翻译文件镜像默认语言路径,缺失翻译时回退并显示语言选择卡片

04

内置 Pagefind 客户端全文搜索,支持 ⌘K / Ctrl+K 快捷键

05

Shiki 代码高亮(明暗主题)、复制按钮和超过 14 行自动折叠

06

通过 config.json 集中配置站点名称、SEO、界面文案和“编辑此页”链接

模板详细介绍

mosona-docs 是一个文档站点模板,使用 React + Vite + Tailwind CSS 4 构建。它从 docs/ 目录读取 Markdown 文件,生成文档页面,并支持多语言、侧边栏导航、页面内目录(TOC)、Shiki 代码高亮、⌘K 全文搜索(基于 Pagefind)、深色模式以及“编辑此页”链接。站点身份、SEO 元数据、界面文案和语言配置集中在根目录的 config.json 中。侧边栏结构由 docs/nav.yaml 定义,未列出的页面会自动归入“More”分组。构建时,默认语言页面会被预渲染为静态 HTML,并生成 Pagefind 搜索索引,最终输出为静态 SPA,需要静态托管并配置 SPA 回退。README 未提供性能数据或生产环境就绪程度的说明。

ViteReact文档

适合你的项目吗?

适用场景

  • 为开源项目或产品编写多语言文档站点
  • 需要静态托管且包含客户端全文搜索的文档场景
  • 希望用 Markdown 管理内容并自定义侧边栏导航的团队
  • 需要深色模式和页面内目录的文档阅读体验

适合人群

  • 熟悉 React 和 Vite 的前端开发者
  • 需要快速搭建文档站点的开源项目维护者
  • 希望以 Markdown 为核心管理文档内容的团队

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    使用 pnpm install 安装依赖,pnpm dev 启动开发服务器

  2. 2

    在 config.json 中配置站点名称、SEO、语言和界面文案

  3. 3

    在 docs/ 目录放置 Markdown 内容,通过 docs/nav.yaml 定义侧边栏结构

  4. 4

    构建时设置 VITE_SITE_URL 以生成正确的 canonical/OG URL、sitemap.xml 和 robots.txt

  5. 5

    构建输出为 dist/ 静态 SPA,需部署到支持 SPA 回退(所有路由指向 index.html)的静态托管服务

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 发布分支前需将 LICENSE 版权行中的 [Your Name] 替换为自己的名称,以保留正确的版权声明。
  • 可选:构建时设置 VITE_SITE_URL 才能生成正确的 canonical/OG URL、sitemap.xml 及 robots.txt 中的 Sitemap 行。
  • docs/zh-CN/guides/deployment.md 被有意省略,用于展示缺失翻译回退;如需完整翻译需自行补充。
  • 构建产物为静态 SPA,需部署到支持 SPA 回退(所有路由指向 index.html)的静态托管服务。
  • 开发模式下搜索不可用,需先执行生产构建生成 Pagefind 索引。
  • 需自行替换 public/og.png(1200×630)为自有社交分享图片,并配置 favicon 等静态资源。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

5. **`LICENSE`** — replace `[Your Name]` in the copyright line before you publish a fork.

README 原文

6. Optional: set `VITE_SITE_URL` at build time for correct canonical/OG URLs, `sitemap.xml`, and the `Sitemap` line in `robots.txt`.

README 原文

- `docs/zh-CN/guides/deployment.md` is **intentionally omitted** so the missing-translation fallback is visible out of the box. Add a translation when you no longer want that demo.

README 原文

The build output is a static SPA in `dist/`. Serve it from any static host with an SPA fallback (all routes → `index.html`). See [docs/guides/deployment.md](docs/guides/deployment.md).

README 原文

Search covers all slugs: every page exists in the default locale by design, so the default-locale index is the whole site. In dev mode the dialog explains that search requires a production build. `dist/pagefind/` deploys like any other static asset — no host configuration needed.

README 原文

4. **`index.html` / `public/`** — favicon and any static assets. Title and description in `index.html` are rewritten from `config.json` at build time. Replace `public/og.png` (1200×630) with your own social image.

README 原文
https://github.com/mosona-labs/mosona-docs/blob/main/LICENSEhttps://github.com/mosona-labs/mosona-docs/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-18。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 85 / 100
技术栈
Vite · React
网站类型
文档
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-08-21
截图检查日期
2026-10-18

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Vite。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261018 · 2026-10-18

查看当时使用的来源资料

SHA-256: 9dc9cba47e5cd6f23b2cc6bbb372e0633f3ec787dd97306f579a36b3b2be7af5

2026-10-18T00:23:26.040Z

来源文件 / 仓库
# Mosona Docs Template

<img width="49.5%" alt="md1" src="https://github.com/user-attachments/assets/2e0b4617-fd20-4a77-b7dc-6489d39d47a0" />
<img width="49.5%" alt="md2" src="https://github.com/user-attachments/assets/3bce5c99-fc8a-44d6-b979-83d135f853c9" />

A docs site template built with React + Vite + Tailwind CSS 4. Markdown in, documentation site out — with multi-language support, sidebar navigation, a page TOC, Shiki code highlighting, ⌘K full-text search (Pagefind), dark mode, and "Edit this page" links.

## Quick start

```bash
pnpm install
pnpm dev
```

## Make it yours

1. **`config.json`** (repo root) — the single place to customize:
    - `site.name`, `site.github`, `site.footerLinks`
    - `seo.defaultTitle`, `seo.description`, `seo.keywords`, `seo.author`, `seo.ogImage`, `seo.ogImageAlt`
    - `locales` + `messages` (UI strings per locale, incl. all home-page copy)
    - `docsGithub` — repository/branch/directory for "Edit this page" links
2. **`docs/`** — your Markdown content. `index.md` is the landing doc at `/docs`.
3. **`docs/nav.yaml`** — sidebar sections and item order. Items are paths relative to the docs root without the `.md` extension (`index` = the landing page). Pages not listed appear under an auto-generated "More" section.
4. **`index.html` / `public/`** — favicon and any static assets. Title and description in `index.html` are rewritten from `config.json` at build time. Replace `public/og.png` (1200×630) with your own social image.
5. **`LICENSE`** — replace `[Your Name]` in the copyright line before you publish a fork.
6. Optional: set `VITE_SITE_URL` at build time for correct canonical/OG URLs, `sitemap.xml`, and the `Sitemap` line in `robots.txt`.

See [CONTRIBUTING.md](CONTRIBUTING.md) if you want to change the template itself.

## Writing docs

- Default-locale pages live directly under `docs/`; translations mirror the same paths inside a locale directory (`docs/zh-CN/guides/foo.md` ↔ `docs/guides/foo.md`). Missing translations fall back to the original with a language picker card.
- `docs/zh-CN/guides/deployment.md` is **intentionally omitted** so the missing-translation fallback is visible out of the box. Add a translation when you no longer want that demo.
- Links ending in `.md` are rewritten to internal router links.
- Fenced code blocks get Shiki highlighting (light/dark), a copy button, and collapse when longer than 14 lines. Supported languages: `src/lib/shiki.ts`.
- `##`/`###` headings feed the right-hand table of contents automatically.
- GFM tables, task lists, and raw HTML are supported.

## Search

Full-text search is powered by [Pagefind](https://pagefind.app/) and runs entirely client-side against a static index — no server needed:

1. `pnpm build` pre-renders every default-locale doc page to static HTML inside `dist/` (`scripts/build-search.mjs`), then runs the Pagefind indexer to produce `dist/pagefind/`.
2. At runtime, the header Search button (or <kbd>⌘K</kbd> / <kbd>Ctrl</kbd>+<kbd>K</kbd>) queries that index via the Pagefind JS API (`src/components/search/docs-search-dialog.tsx`).
3. Results link back into the SPA routes via each page's canonical URL.

Search covers all slugs: every page exists in the default locale by design, so the default-locale index is the whole site. In dev mode the dialog explains that search requires a production build. `dist/pagefind/` deploys like any other static asset — no host configuration needed.

Alternatives (Algolia DocSearch, a client-side filter over `src/lib/docs.ts`) can replace this if your project outgrows Pagefind.

## Scripts

| Script            | Purpose                       |
| ----------------- | ----------------------------- |
| `pnpm dev`        | Dev server                    |
| `pnpm build`      | Type-check + production build + Pagefind index |
| `pnpm preview`    | Preview the production build  |
| `pnpm check`      | Biome lint + format check     |
| `pnpm fix`        | Biome autofix                 |
| `pnpm test`       | Unit tests                    |
| `pnpm test:watch` | Unit tests in watch mode      |
| `pnpm typecheck`  | `tsc --noEmit`                |

## Deployment

The build output is a static SPA in `dist/`. Serve it from any static host with an SPA fallback (all routes → `index.html`). See [docs/guides/deployment.md](docs/guides/deployment.md).

## Project structure

```text
├── config.json            # Site identity, locales, messages, SEO, docs GitHub
├── docs/                  # Your Markdown content + nav.yaml
│   └── <locale>/          # Translations mirroring default-locale paths
├── public/                # Static assets (favicon, og.png, robots.txt)
├── scripts/
│   └── build-search.mjs   # Prerenders docs HTML + runs Pagefind (post-build)
└── src/
    ├── components/
    │   ├── docs/          # Sidebar, mobile nav, TOC, markdown renderer,
    │   │                  # collapsible code block, missing-translation card
    │   ├── search/        # ⌘K search dialog (Pagefind JS API)
    │   └── ui/            # Button (shadcn-style)
    ├── hooks/             # usePageSeo
    ├── lib/
    │   ├── docs.ts        # Loads docs/, parses slugs/headings, builds nav
    │   ├── i18n.ts        # Locale detection & messages (from config.json)
    │   ├── seo.ts         # Per-page meta tags
    │   └── shiki.ts       # Code highlighting config
    ├── pages/             # Home page, docs page, 404
    └── search/            # prerender-docs.tsx (Pagefind index source)
```

## License

MIT — see [LICENSE](LICENSE).
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。