@rspress/core 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bb~0.js +1 -0
- package/dist/b~0.js +3026 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Callout/index.test.tsx +52 -0
- package/dist/eject-theme/components/Callout/index.tsx +11 -0
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/HomeFeature/index.scss +12 -0
- package/dist/eject-theme/components/HomeHero/index.scss +4 -1
- package/dist/eject-theme/components/PageTabs/index.test.tsx +45 -0
- package/dist/eject-theme/components/PageTabs/index.tsx +17 -0
- package/dist/eject-theme/components/Prompt/index.tsx +2 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.scss +14 -0
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +6 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -10
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +2 -2
- package/dist/eject-theme/components/Tabs/index.test.tsx +26 -4
- package/dist/eject-theme/components/Tabs/index.tsx +8 -5
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +6 -1
- package/dist/node/mdx/options.js +1 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +19 -3
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/route/routeChunkAssets.d.ts +2 -0
- package/dist/node/route/routeChunkAssets.js +6 -0
- package/dist/node/runtimeModule/i18n/getI18nData.js +1 -1
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.js +1 -1
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +5 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +1 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.d.ts +0 -4
- package/dist/node/ssg-md/remarkSplitMdx.js +266 -163
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +3 -1
- package/dist/n~0.js +1 -1
- package/dist/{tx~0.js → q~0.js} +3 -3
- package/dist/shiki-transformers.js +1 -1
- package/dist/theme/components/Callout/index.js +10 -0
- package/dist/theme/components/CodeBlock/index.d.ts +1 -1
- package/dist/theme/components/HomeFeature/index.css +10 -0
- package/dist/theme/components/HomeHero/index.css +5 -1
- package/dist/theme/components/PageTabs/index.js +12 -0
- package/dist/theme/components/Prompt/index.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.css +14 -0
- package/dist/theme/components/Sidebar/SidebarGroup.js +29 -22
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -10
- package/dist/theme/components/Sidebar/SidebarItem.js +2 -2
- package/dist/theme/components/Tabs/index.js +8 -5
- package/dist/tinypool~0.js +2 -2
- package/dist/y~0.js +1 -1
- package/package.json +14 -11
- package/skills/rspress-best-practices/SKILL.md +82 -0
- package/skills/rspress-custom-theme/SKILL.md +242 -0
- package/skills/rspress-custom-theme/references/css-variables.md +177 -0
- package/skills/rspress-custom-theme/references/eject-components.md +154 -0
- package/skills/rspress-custom-theme/references/layout-slots.md +153 -0
- package/skills/rspress-description-generator/SKILL.md +118 -0
- package/skills/rspress-docs-generator/SKILL.md +60 -0
- package/skills/rspress-docs-generator/references/create-new-docs.md +73 -0
- package/skills/rspress-docs-generator/references/doc-structure-conventions.md +117 -0
- package/skills/rspress-docs-generator/references/maintain-docs-for-prs.md +31 -0
- package/skills/rspress-docs-generator/references/rspress-version-guard.md +13 -0
- package/dist/p~0.js +0 -3032
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Layout slots reference
|
|
2
|
+
|
|
3
|
+
The `Layout` component accepts slot props (`React.ReactNode`) for injecting content at specific positions without replacing built-in components. This is the recommended way to extend Rspress before considering eject.
|
|
4
|
+
|
|
5
|
+
Official reference: <https://rspress.rs/ui/layout-components/layout>
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## All available slots
|
|
10
|
+
|
|
11
|
+
### Navigation bar
|
|
12
|
+
|
|
13
|
+
| Slot | Position |
|
|
14
|
+
| ---------------- | ------------------------------------ |
|
|
15
|
+
| `beforeNav` | Before the entire navigation bar |
|
|
16
|
+
| `afterNav` | After the entire navigation bar |
|
|
17
|
+
| `beforeNavTitle` | Before the nav title/logo (top-left) |
|
|
18
|
+
| `navTitle` | Replaces the nav title content |
|
|
19
|
+
| `afterNavTitle` | After the nav title/logo |
|
|
20
|
+
| `beforeNavMenu` | Before the nav menu items |
|
|
21
|
+
| `afterNavMenu` | After the nav menu items |
|
|
22
|
+
|
|
23
|
+
### Sidebar & outline
|
|
24
|
+
|
|
25
|
+
| Slot | Position |
|
|
26
|
+
| --------------- | ----------------------------------- |
|
|
27
|
+
| `beforeSidebar` | Above the left sidebar |
|
|
28
|
+
| `afterSidebar` | Below the left sidebar |
|
|
29
|
+
| `beforeOutline` | Above the right outline (TOC) panel |
|
|
30
|
+
| `afterOutline` | Below the right outline panel |
|
|
31
|
+
|
|
32
|
+
### Home page
|
|
33
|
+
|
|
34
|
+
| Slot | Position |
|
|
35
|
+
| ---------------- | ------------------------ |
|
|
36
|
+
| `beforeHero` | Before the Hero section |
|
|
37
|
+
| `afterHero` | After the Hero section |
|
|
38
|
+
| `beforeFeatures` | Before the Features grid |
|
|
39
|
+
| `afterFeatures` | After the Features grid |
|
|
40
|
+
|
|
41
|
+
### Doc page
|
|
42
|
+
|
|
43
|
+
| Slot | Position |
|
|
44
|
+
| ------------------ | ------------------------------------- |
|
|
45
|
+
| `beforeDoc` | At the very beginning of the doc page |
|
|
46
|
+
| `afterDoc` | At the very end of the doc page |
|
|
47
|
+
| `beforeDocContent` | Before the document content area |
|
|
48
|
+
| `afterDocContent` | After the document content area |
|
|
49
|
+
| `beforeDocFooter` | Before the doc footer (prev/next nav) |
|
|
50
|
+
| `afterDocFooter` | After the doc footer |
|
|
51
|
+
|
|
52
|
+
### Global
|
|
53
|
+
|
|
54
|
+
| Slot | Position |
|
|
55
|
+
| ------------ | ---------------------------------------------------------------------- |
|
|
56
|
+
| `top` | At the very top of the entire page |
|
|
57
|
+
| `bottom` | At the very bottom of the entire page |
|
|
58
|
+
| `components` | Custom MDX component overrides (`Record<string, React.ComponentType>`) |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Usage pattern
|
|
63
|
+
|
|
64
|
+
All examples below follow the same structure in `theme/index.tsx`. The key parts:
|
|
65
|
+
|
|
66
|
+
- Import `Layout` from `@rspress/core/theme-original` (not `@rspress/core/theme` — that causes circular imports)
|
|
67
|
+
- Re-export everything: `export * from '@rspress/core/theme-original'`
|
|
68
|
+
- Export your custom `Layout` that wraps the original with slot props
|
|
69
|
+
|
|
70
|
+
### Basic — single slot
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
// theme/index.tsx
|
|
74
|
+
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
|
75
|
+
export * from '@rspress/core/theme-original';
|
|
76
|
+
|
|
77
|
+
export function Layout() {
|
|
78
|
+
return <OriginalLayout beforeNavTitle={<MyLogo />} />;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Multiple slots
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
// theme/index.tsx
|
|
86
|
+
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
|
87
|
+
export * from '@rspress/core/theme-original';
|
|
88
|
+
|
|
89
|
+
export function Layout() {
|
|
90
|
+
return (
|
|
91
|
+
<OriginalLayout
|
|
92
|
+
top={<div className="announcement-bar">New version released!</div>}
|
|
93
|
+
bottom={<footer>© 2025 My Company</footer>}
|
|
94
|
+
afterOutline={<div>Related resources</div>}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### With i18n hooks
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
// theme/index.tsx
|
|
104
|
+
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
|
105
|
+
import { useLang } from '@rspress/core/runtime';
|
|
106
|
+
export * from '@rspress/core/theme-original';
|
|
107
|
+
|
|
108
|
+
function LocalizedBanner() {
|
|
109
|
+
const lang = useLang();
|
|
110
|
+
return <div>{lang === 'zh' ? '欢迎' : 'Welcome'}</div>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function Layout() {
|
|
114
|
+
return <OriginalLayout top={<LocalizedBanner />} />;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Override MDX components
|
|
119
|
+
|
|
120
|
+
The `components` slot accepts a `Record<string, React.ComponentType>` to override how MDX elements render:
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
// theme/index.tsx
|
|
124
|
+
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
|
125
|
+
export * from '@rspress/core/theme-original';
|
|
126
|
+
|
|
127
|
+
function CustomH1({ children }: { children: React.ReactNode }) {
|
|
128
|
+
return (
|
|
129
|
+
<h1 style={{ borderBottom: '2px solid var(--rp-c-brand)' }}>{children}</h1>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function Layout() {
|
|
134
|
+
return <OriginalLayout components={{ h1: CustomH1 }} />;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Available hooks
|
|
141
|
+
|
|
142
|
+
Use these hooks inside slot components. Import from `@rspress/core/runtime`.
|
|
143
|
+
|
|
144
|
+
| Hook | Purpose |
|
|
145
|
+
| ------------------ | ----------------------------------- |
|
|
146
|
+
| `useDark()` | Returns whether dark mode is active |
|
|
147
|
+
| `useLang()` | Returns current language code |
|
|
148
|
+
| `useVersion()` | Returns current doc version |
|
|
149
|
+
| `usePage()` | Returns current page metadata |
|
|
150
|
+
| `usePages()` | Returns all pages metadata |
|
|
151
|
+
| `useSite()` | Returns site-level configuration |
|
|
152
|
+
| `useFrontmatter()` | Returns current page frontmatter |
|
|
153
|
+
| `useI18n()` | Returns i18n translation function |
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rspress-description-generator
|
|
3
|
+
description: Generate missing description frontmatter for Rspress Markdown/MDX pages, including new docs pages and site-wide SEO metadata updates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rspress description generator
|
|
7
|
+
|
|
8
|
+
The `description` field in Rspress frontmatter generates `<meta name="description" content="...">` tags, which are used for search engine snippets, social media previews, and AI-oriented formats like llms.txt.
|
|
9
|
+
|
|
10
|
+
## Step 1 — locate the docs root
|
|
11
|
+
|
|
12
|
+
1. Find the Rspress config file. Search for `rspress.config.ts`, `.js`, `.mjs`, or `.cjs`. It may be at the project root or inside a subdirectory like `website/`.
|
|
13
|
+
2. Read the config and extract the `root` option.
|
|
14
|
+
- The value might be a plain string (`root: 'docs'`) or a JS expression (`root: path.join(__dirname, 'docs')`). In either case, determine the resolved directory path.
|
|
15
|
+
- If `root` is set, resolve it relative to the config file's directory.
|
|
16
|
+
- If `root` is not set, default to `docs` relative to the config file's directory.
|
|
17
|
+
3. Confirm the directory exists. If neither `docs` nor the configured root exists, check for `doc` as a fallback.
|
|
18
|
+
|
|
19
|
+
## Step 2 — detect i18n structure
|
|
20
|
+
|
|
21
|
+
Rspress i18n projects place language subdirectories (e.g., `en/`, `zh/`) directly under the docs root:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
docs/
|
|
25
|
+
├── en/
|
|
26
|
+
│ ├── guide/
|
|
27
|
+
│ └── index.md
|
|
28
|
+
└── zh/
|
|
29
|
+
├── guide/
|
|
30
|
+
└── index.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Check if the docs root contains language subdirectories (two-letter codes like `en`, `zh`, `ja`, `ko`, etc.). If so, process each language directory separately — the description language should match the content language.
|
|
34
|
+
|
|
35
|
+
If there are no language subdirectories, treat the entire docs root as a single-language site.
|
|
36
|
+
|
|
37
|
+
## Step 3 — scan and process files
|
|
38
|
+
|
|
39
|
+
Glob for `**/*.md` and `**/*.mdx` under the docs root. Exclude:
|
|
40
|
+
|
|
41
|
+
- `node_modules`, build output (`doc_build`, `.rspress`, `dist`)
|
|
42
|
+
- `_meta.json` / `_nav.json` (sidebar/nav config files, not doc pages)
|
|
43
|
+
- `**/shared/**` directories (reusable snippets included via `@import`, not standalone pages)
|
|
44
|
+
|
|
45
|
+
For each file:
|
|
46
|
+
|
|
47
|
+
1. **Read the file.**
|
|
48
|
+
2. **Check for existing `description` in frontmatter.** If it exists and is non-empty, skip.
|
|
49
|
+
3. **Check `pageType` in frontmatter.** For `home` pages, derive the description from the `hero.text` / `hero.tagline` fields or the features list, not from body content.
|
|
50
|
+
4. **Generate a description** following the writing guidelines below.
|
|
51
|
+
5. **Insert `description` into frontmatter:**
|
|
52
|
+
- If the file has frontmatter with a `title` field, insert `description` on the line after `title`.
|
|
53
|
+
- If the file has frontmatter without `title`, insert `description` as the first field.
|
|
54
|
+
- If the file has no frontmatter block, add one:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
---
|
|
58
|
+
description: Your generated description here
|
|
59
|
+
---
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### YAML formatting
|
|
63
|
+
|
|
64
|
+
Most descriptions can be bare YAML strings:
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
description: Step-by-step guide to setting up your first Rspress site
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If the description contains colons, quotes, or other special YAML characters, wrap in double quotes:
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
description: 'API reference for Rspress configuration: plugins, themes, and build options'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Step 4 — batch processing
|
|
77
|
+
|
|
78
|
+
For sites with many files, use parallel agent calls to process independent files simultaneously. Group by directory (e.g., all files in `guide/`, then all in `api/`) to maintain focus and consistency within each section.
|
|
79
|
+
|
|
80
|
+
After processing all files, do a quick scan to ensure no files were missed — re-glob and check for any remaining files without `description`.
|
|
81
|
+
|
|
82
|
+
## Description writing guidelines
|
|
83
|
+
|
|
84
|
+
The description serves three audiences: search engines (Google snippet), AI systems (llms.txt, summarization), and humans (scanning search results). A good description helps all three.
|
|
85
|
+
|
|
86
|
+
### Rules
|
|
87
|
+
|
|
88
|
+
- **Length**: 50–160 characters. Under 50 is too vague for search engines; over 160 gets truncated in snippets.
|
|
89
|
+
- **Language**: Match the document content. Chinese docs get Chinese descriptions, English docs get English descriptions.
|
|
90
|
+
- **Be direct**: State what the page covers. Avoid starting with "This document", "This page", "Learn about" — jump straight to the substance.
|
|
91
|
+
- **Be specific**: Mention concrete technologies, APIs, or concepts the page covers. "Configure Rspress plugins for search, analytics, and internationalization" beats "How to use plugins."
|
|
92
|
+
- **No markdown**: Plain text only, no formatting syntax.
|
|
93
|
+
|
|
94
|
+
### Examples
|
|
95
|
+
|
|
96
|
+
**Good:**
|
|
97
|
+
|
|
98
|
+
| Content | Description |
|
|
99
|
+
| -------------------------- | ---------------------------------------------------------------------------- |
|
|
100
|
+
| Plugin development guide | Create custom Rspress plugins using the Node.js plugin API and runtime hooks |
|
|
101
|
+
| MDX component usage | Import and use React components in MDX documentation files |
|
|
102
|
+
| Rspress 快速开始 | 从安装到本地预览,搭建 Rspress 文档站点的完整流程 |
|
|
103
|
+
| 主题配置 | 自定义 Rspress 主题的导航栏、侧边栏、页脚和暗色模式 |
|
|
104
|
+
| Home page (pageType: home) | Rspress documentation framework — fast, MDX-powered static site generator |
|
|
105
|
+
|
|
106
|
+
**Bad:**
|
|
107
|
+
|
|
108
|
+
| Description | Why |
|
|
109
|
+
| ------------------------------------------------------- | ------------------------------------------------ |
|
|
110
|
+
| "About plugins" | Too vague — which plugins? what about them? |
|
|
111
|
+
| "This page explains how to configure the Rspress theme" | Wastes characters on "This page explains how to" |
|
|
112
|
+
| "Learn everything about Rspress!" | Marketing fluff, says nothing specific |
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
- Frontmatter fields: <https://rspress.rs/api/config/config-frontmatter>
|
|
117
|
+
- Basic config (`root` option): <https://rspress.rs/api/config/config-basic>
|
|
118
|
+
- Full Rspress docs: <https://rspress.rs/llms.txt>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rspress-docs-generator
|
|
3
|
+
description: Create a Rspress v2 docs site or maintain existing Rspress v2 documentation for project changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rspress docs generator
|
|
7
|
+
|
|
8
|
+
Create and maintain Rspress documentation as part of normal project work. Prefer source-backed docs over generic prose: read the code, tests, examples, package metadata, and existing README before writing.
|
|
9
|
+
|
|
10
|
+
## Use cases
|
|
11
|
+
|
|
12
|
+
- Create a new Rspress v2 documentation site for a project that has no docs site yet.
|
|
13
|
+
- Update an existing Rspress v2 docs site for a user-facing feature, API change, CLI change, or PR.
|
|
14
|
+
- Detect Rspress v1 version markers before documentation work and hand migration to the dedicated `rspress-v2-upgrade` skill.
|
|
15
|
+
- Integrate Rspress documentation into an Rslib package or workspace while preserving the repository's package manager and scripts.
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
1. **Inspect the project**
|
|
20
|
+
- Locate package files, source entry points, examples, tests, changelogs, and README files.
|
|
21
|
+
- Search for Rspress config files: `rspress.config.ts`, `.js`, `.mjs`, or `.cjs`.
|
|
22
|
+
- Inspect dependencies for Rspress version markers: `@rspress/core` version, legacy `rspress` package or `rspress/*` imports, and `@rspress/plugin-*`.
|
|
23
|
+
- Detect the package manager and workspace setup from lock files (`pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`, `bun.lock`, `bun.lockb`) and `pnpm-workspace.yaml`.
|
|
24
|
+
- If a config exists, resolve the docs root from its `root` option. When `root` is absent, inspect package scripts, CI commands, and documented commands for Rspress CLI positional roots such as `rspress dev site`, `rspress build site`, or `rspress preview site`; use that argument before falling back to Rspress's default `docs/` directory relative to the config file's project cwd. If no config exists, check common roots such as `docs/`, `doc/`, `website/`, and `site/`.
|
|
25
|
+
|
|
26
|
+
2. **Choose the correct path**
|
|
27
|
+
- If no Rspress docs site exists, follow [Create New Docs](references/create-new-docs.md).
|
|
28
|
+
- If a Rspress docs site exists but appears to be v1, follow [Rspress Version Guard](references/rspress-version-guard.md) before editing docs.
|
|
29
|
+
- If a Rspress v2 docs site exists, follow [Maintain Docs For PRs](references/maintain-docs-for-prs.md).
|
|
30
|
+
|
|
31
|
+
3. **Validate before finishing**
|
|
32
|
+
- Run the docs build from the Rspress project directory or through the repo's root script.
|
|
33
|
+
- The build must pass as the primary success criterion.
|
|
34
|
+
- Fix broken links, missing navigation entries, invalid frontmatter, and failed MDX imports before reporting completion.
|
|
35
|
+
|
|
36
|
+
## Code examples
|
|
37
|
+
|
|
38
|
+
Use the repository's package manager when creating or validating docs:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Create a new Rspress docs site with the detected package manager.
|
|
42
|
+
# Replace pnpm with npm, yarn, or bun when that is the repo package manager.
|
|
43
|
+
pnpm create rspress@latest
|
|
44
|
+
|
|
45
|
+
# Validate from the docs project after replacing starter content.
|
|
46
|
+
pnpm run build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
When maintaining docs for a PR, inspect the changed source first, then update the matching docs page and navigation:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
src/formatBytes.ts -> website/docs/api/formatBytes.mdx -> website/docs/api/_meta.json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Reference
|
|
56
|
+
|
|
57
|
+
- [Documentation structure conventions](references/doc-structure-conventions.md) — how `_nav.json` and `_meta.json` work, with concrete examples for Guide/API sites, grouped sections, and i18n layouts.
|
|
58
|
+
- [Create New Docs](references/create-new-docs.md) — scaffold a Rspress v2 docs site from an undocumented project.
|
|
59
|
+
- [Maintain Docs For PRs](references/maintain-docs-for-prs.md) — update an existing Rspress v2 docs site for feature work.
|
|
60
|
+
- [Rspress Version Guard](references/rspress-version-guard.md) — detect v1 sites, avoid stale v1 scaffolds, and hand full migration to `rspress-v2-upgrade`.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Create new docs
|
|
2
|
+
|
|
3
|
+
Use this path when the current project has no existing Rspress documentation site.
|
|
4
|
+
|
|
5
|
+
1. **Understand the project from source**
|
|
6
|
+
- Read the root `README.md` and main `package.json`.
|
|
7
|
+
- Identify the project type: library, CLI tool, application, plugin, monorepo package, etc.
|
|
8
|
+
- Read public source entry points, exported types, examples, and representative tests to understand the user-facing surface.
|
|
9
|
+
- Determine the target audience and what to document: getting started, configuration, API reference, CLI commands, examples, migration notes, or plugin usage.
|
|
10
|
+
- Cross-check Rspress basics against the official docs when choosing structure or syntax:
|
|
11
|
+
- Quick start: <https://rspress.rs/guide/start/getting-started>
|
|
12
|
+
- Conventional route: <https://rspress.rs/guide/basic/conventional-route>
|
|
13
|
+
- Frontmatter: <https://rspress.rs/guide/use-mdx/frontmatter>
|
|
14
|
+
|
|
15
|
+
2. **Choose the docs site location**
|
|
16
|
+
- If the repository already has a conventional docs directory (`docs/`, `doc/`, `website/`, `site/`), prefer reusing it.
|
|
17
|
+
- Otherwise, propose a short list of options to the user, such as `website/`, `docs/`, or `site/`, and ask which to use.
|
|
18
|
+
- For monorepos, place the docs site so it can reference workspace packages without crossing too many directory boundaries.
|
|
19
|
+
|
|
20
|
+
3. **Scaffold Rspress v2**
|
|
21
|
+
- See the official getting-started guide for the latest creation steps:
|
|
22
|
+
- <https://rspress.rs/guide/start/getting-started>
|
|
23
|
+
- Scaffold with the package manager used by the repo. Run one command that matches the detected package manager:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# interactive (recommended for first-time setup)
|
|
27
|
+
pnpm create rspress@latest
|
|
28
|
+
yarn create rspress@latest
|
|
29
|
+
npm create rspress@latest
|
|
30
|
+
bun create rspress@latest
|
|
31
|
+
|
|
32
|
+
# or non-interactive, e.g. for CI/automation
|
|
33
|
+
pnpm dlx create-rspress@latest my-docs --template basic-theme --tools rslint,prettier
|
|
34
|
+
yarn dlx create-rspress@latest my-docs --template basic-theme --tools rslint,prettier
|
|
35
|
+
npx -y create-rspress@latest my-docs --template basic-theme --tools rslint,prettier
|
|
36
|
+
bun x create-rspress@latest my-docs --template basic-theme --tools rslint,prettier
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- After scaffolding, verify the generated docs `package.json` depends on Rspress v2 through `@rspress/core` with a 2.x range. Do not accept a generated `rspress` dependency as v2. If the generated dependency is missing, still v1, or uses the legacy `rspress` package, rerun the scaffold with the detected package manager and pin the scaffold package to a known v2-compatible version, such as `<package-manager> create rspress@2` or `npx -y create-rspress@2`.
|
|
40
|
+
- Prefer the detected package manager for installs and scripts. Do not introduce a second package manager or extra lockfile into an existing workspace.
|
|
41
|
+
- Pick a template that matches the project:
|
|
42
|
+
- `basic` — minimal site with the default theme.
|
|
43
|
+
- `basic-theme` — adds a `theme/` folder for customization.
|
|
44
|
+
- `i18n` — multilingual English/Chinese setup.
|
|
45
|
+
- `i18n-theme` — multilingual setup with a theme folder.
|
|
46
|
+
- If the project uses Rslib, follow the Rslib + Rspress integration guide instead of the generic scaffold:
|
|
47
|
+
- <https://rslib.rs/guide/advanced/rspress.md>
|
|
48
|
+
|
|
49
|
+
4. **After scaffolding**
|
|
50
|
+
- Install dependencies:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd <docs-project>
|
|
54
|
+
<package-manager> install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- In automated or non-interactive runs, do not run an unbounded dev server. If a dev-server smoke test is useful in an interactive run, start `<package-manager> run dev` with an explicit timeout or background process, confirm it starts, then terminate it before continuing.
|
|
58
|
+
- Check the current Node.js requirement from the official Rspress docs or the installed `@rspress/core` package's `engines.node` field. Compare it with the repo's configured Node version and surface any mismatch before proceeding.
|
|
59
|
+
- Default build output goes to `doc_build/`. Keep it out of source control unless the repository already commits it.
|
|
60
|
+
|
|
61
|
+
5. **Replace starter content**
|
|
62
|
+
- Remove placeholder pages that do not describe the project.
|
|
63
|
+
- Write source-backed pages from the project README, package exports, public types, examples, and tests.
|
|
64
|
+
- Add `title` and `description` frontmatter to each page.
|
|
65
|
+
- Configure navigation with `_nav.json` (top navbar) and `_meta.json` (sidebar) where the generated structure needs explicit labels or order. See [doc-structure-conventions.md](doc-structure-conventions.md) for examples.
|
|
66
|
+
- Follow official Rspress guidance for content features before inventing custom patterns:
|
|
67
|
+
- MDX and React components: <https://rspress.rs/guide/use-mdx/components>
|
|
68
|
+
- Code blocks: <https://rspress.rs/guide/use-mdx/code-blocks>
|
|
69
|
+
- Links: <https://rspress.rs/guide/use-mdx/link>
|
|
70
|
+
- Static assets: <https://rspress.rs/guide/basic/static-assets>
|
|
71
|
+
|
|
72
|
+
6. **Wire project commands**
|
|
73
|
+
- Add or reuse scripts for docs development and build, such as `docs:dev` and `docs:build`, following the repo's package manager and workspace conventions.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Documentation structure conventions
|
|
2
|
+
|
|
3
|
+
Rspress generates navigation automatically when `rspress.config.ts` does not define `nav` or `sidebar`. Control the result with `_nav.json` (top navbar) and `_meta.json` (sidebar).
|
|
4
|
+
|
|
5
|
+
Official reference:
|
|
6
|
+
|
|
7
|
+
- Autogenerated navigation: <https://rspress.rs/guide/basic/auto-nav-sidebar>
|
|
8
|
+
|
|
9
|
+
- Place `_nav.json` at the docs root (or at the i18n language root such as `docs/en/`).
|
|
10
|
+
- Place `_meta.json` inside each subdirectory that needs explicit sidebar labels, order, or grouping.
|
|
11
|
+
- For clickable directories, add an `index.mdx` (or `index.md`) inside the directory.
|
|
12
|
+
- In leaf directories with only files, `_meta.json` can be omitted when alphabetical order is acceptable. Use `_meta.json` to customize order or labels; only preserve numeric filename prefixes when the repository already uses that convention.
|
|
13
|
+
|
|
14
|
+
## Example 1: simple guide + API site
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
docs/
|
|
18
|
+
├── _nav.json
|
|
19
|
+
├── guide/
|
|
20
|
+
│ ├── _meta.json
|
|
21
|
+
│ ├── index.mdx
|
|
22
|
+
│ ├── getting-started.mdx
|
|
23
|
+
│ └── configuration.mdx
|
|
24
|
+
└── api/
|
|
25
|
+
├── _meta.json
|
|
26
|
+
├── index.mdx
|
|
27
|
+
└── commands.mdx
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`docs/_nav.json`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
[
|
|
34
|
+
{ "text": "Guide", "link": "/guide/", "activeMatch": "/guide/" },
|
|
35
|
+
{ "text": "API", "link": "/api/", "activeMatch": "/api/" }
|
|
36
|
+
]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`docs/guide/_meta.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
[
|
|
43
|
+
{ "type": "file", "name": "index", "label": "Overview" },
|
|
44
|
+
"getting-started",
|
|
45
|
+
"configuration"
|
|
46
|
+
]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`docs/api/_meta.json`:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
[{ "type": "file", "name": "index", "label": "Overview" }, "commands"]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Example 2: site with grouped sections
|
|
56
|
+
|
|
57
|
+
A larger site can use `dir-section-header` to group related directories in the sidebar.
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
docs/
|
|
61
|
+
├── _nav.json
|
|
62
|
+
├── guide/
|
|
63
|
+
│ ├── _meta.json
|
|
64
|
+
│ ├── start/
|
|
65
|
+
│ │ ├── index.mdx
|
|
66
|
+
│ │ ├── introduction.mdx
|
|
67
|
+
│ │ └── getting-started.mdx
|
|
68
|
+
│ ├── basic/
|
|
69
|
+
│ │ ├── index.mdx
|
|
70
|
+
│ │ └── auto-nav-sidebar.mdx
|
|
71
|
+
│ └── advanced/
|
|
72
|
+
│ └── custom-theme.mdx
|
|
73
|
+
└── api/
|
|
74
|
+
├── _meta.json
|
|
75
|
+
├── index.mdx
|
|
76
|
+
└── config/
|
|
77
|
+
├── _meta.json
|
|
78
|
+
├── index.mdx
|
|
79
|
+
└── build.mdx
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`docs/guide/_meta.json`:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
[
|
|
86
|
+
{ "type": "dir-section-header", "name": "start", "label": "Getting Started" },
|
|
87
|
+
{ "type": "dir-section-header", "name": "basic", "label": "Features" },
|
|
88
|
+
{ "type": "dir-section-header", "name": "advanced", "label": "Advanced" }
|
|
89
|
+
]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`docs/api/_meta.json`:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
[
|
|
96
|
+
{ "type": "section-header", "label": "Overview" },
|
|
97
|
+
{ "type": "file", "name": "index", "label": "API Overview" },
|
|
98
|
+
{ "type": "section-header", "label": "Config" },
|
|
99
|
+
{ "type": "dir", "name": "config", "label": "Config Options" }
|
|
100
|
+
]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Example 3: i18n layout
|
|
104
|
+
|
|
105
|
+
For multilingual sites, place `_nav.json` inside each language root and keep the same directory shape across locales.
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
docs/
|
|
109
|
+
├── en/
|
|
110
|
+
│ ├── _nav.json
|
|
111
|
+
│ ├── guide/
|
|
112
|
+
│ └── api/
|
|
113
|
+
└── zh/
|
|
114
|
+
├── _nav.json
|
|
115
|
+
├── guide/
|
|
116
|
+
└── api/
|
|
117
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Maintain docs for PRs
|
|
2
|
+
|
|
3
|
+
Use this path when a Rspress v2 docs site already exists.
|
|
4
|
+
|
|
5
|
+
1. **Connect docs work to the change**
|
|
6
|
+
- If a PR already exists, read its title, description, linked issues, and the full PR diff.
|
|
7
|
+
- If no PR exists yet, inspect the current branch diff against the base branch using `git merge-base` and `git diff`.
|
|
8
|
+
- Identify user-facing changes: new APIs, config options, CLI flags, plugins, behavior changes, migration notes, deprecations, examples, or breaking changes.
|
|
9
|
+
- Use the PR title or conventional commit category as one signal, but also exercise independent judgment about whether the change affects users.
|
|
10
|
+
- If the change has no user-facing impact, report that no docs update is needed and explain why.
|
|
11
|
+
|
|
12
|
+
2. **Update the right pages**
|
|
13
|
+
- Modify existing pages before adding new pages when the change belongs in an established guide or API reference.
|
|
14
|
+
- Add new pages only for new workflows or concepts that need their own sidebar or top navigation entry.
|
|
15
|
+
- Keep examples minimal, runnable, and version-accurate.
|
|
16
|
+
- Add or update `description` frontmatter for every touched or created doc page.
|
|
17
|
+
- Update `_meta.json` whenever a new page should appear in the sidebar. Update the docs root `_nav.json` only when the page or section should appear in the top navigation. See [doc-structure-conventions.md](doc-structure-conventions.md) for examples.
|
|
18
|
+
- Use official Rspress docs to confirm syntax and conventions before adding new patterns:
|
|
19
|
+
- Frontmatter: <https://rspress.rs/guide/use-mdx/frontmatter>
|
|
20
|
+
- MDX and React components: <https://rspress.rs/guide/use-mdx/components>
|
|
21
|
+
- Links: <https://rspress.rs/guide/use-mdx/link>
|
|
22
|
+
- Autogenerated navigation: <https://rspress.rs/guide/basic/auto-nav-sidebar>
|
|
23
|
+
|
|
24
|
+
3. **Respect existing docs conventions**
|
|
25
|
+
- Match the site's language, tone, directory structure, i18n layout, frontmatter style, and MDX component patterns.
|
|
26
|
+
- For i18n sites, update all required locales or explicitly note which locale remains pending.
|
|
27
|
+
- Prefer first-class Rspress options and documented theme APIs over custom workarounds.
|
|
28
|
+
|
|
29
|
+
4. **Validate the documentation**
|
|
30
|
+
- Run the docs build from the Rspress project directory or through the repo's root script.
|
|
31
|
+
- If docs build is expensive or unavailable, at least validate changed Markdown/MDX structure, links, imports, navigation files, and frontmatter.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Rspress version guard
|
|
2
|
+
|
|
3
|
+
Use this path when a docs site exists but may depend on Rspress v1, or when a newly scaffolded docs site must be checked before content work. This skill should keep documentation work on Rspress v2 and avoid accidentally creating or maintaining a stale v1 project.
|
|
4
|
+
|
|
5
|
+
1. Check the docs project's dependencies and imports:
|
|
6
|
+
- Rspress v2 projects should depend on `@rspress/core` with a 2.x range.
|
|
7
|
+
- A `rspress` package dependency, `@rspress/core` 1.x, `@rspress/theme-default`, `@rspress/runtime`, or imports such as `rspress/runtime` and `rspress/theme` are v1 migration signals.
|
|
8
|
+
2. If the site is already on Rspress v2, continue with [Maintain Docs For PRs](maintain-docs-for-prs.md).
|
|
9
|
+
3. If v1 migration signals are present, do not perform the full migration in this skill. Report that the docs site must be upgraded first and use the dedicated `rspress-v2-upgrade` skill for the migration.
|
|
10
|
+
4. Keep the official migration guide as the fallback source of truth if the upgrade skill is unavailable or more detail is needed:
|
|
11
|
+
- Migration guide: <https://rspress.rs/guide/migration/rspress-1-x>
|
|
12
|
+
- Legacy Rspress 1.x docs: <https://v1.rspress.rs>
|
|
13
|
+
5. After the upgrade build passes, return to this skill for source-backed documentation updates.
|