@rspress/core 2.1.4 → 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.
Files changed (74) hide show
  1. package/dist/bb~0.js +1 -0
  2. package/dist/b~0.js +3026 -1
  3. package/dist/cli/index.js +1 -1
  4. package/dist/config/loadConfigFile.js +1 -1
  5. package/dist/eject-theme/components/HomeFeature/index.scss +12 -0
  6. package/dist/eject-theme/components/Sidebar/SidebarGroup.scss +14 -0
  7. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +6 -1
  8. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -10
  9. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +2 -2
  10. package/dist/node/PluginDriver.js +1 -1
  11. package/dist/node/auto-nav-sidebar/index.js +1 -1
  12. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  13. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  14. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  15. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  16. package/dist/node/eject.js +1 -1
  17. package/dist/node/initRsbuild.js +1 -1
  18. package/dist/node/mdx/options.js +1 -1
  19. package/dist/node/mdx/processor.js +1 -1
  20. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  21. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  22. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  23. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  24. package/dist/node/route/RoutePage.js +1 -1
  25. package/dist/node/route/RouteService.js +1 -1
  26. package/dist/node/route/extractPageData.js +1 -1
  27. package/dist/node/route/normalizeRoutePath.js +1 -1
  28. package/dist/node/runtimeModule/i18n/getI18nData.js +1 -1
  29. package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +1 -1
  30. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  31. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  32. package/dist/node/runtimeModule/searchHooks.js +1 -1
  33. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  34. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  35. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  36. package/dist/node/serve.js +1 -1
  37. package/dist/node/sitemap.js +1 -1
  38. package/dist/node/ssg/alternateLinks.js +1 -1
  39. package/dist/node/ssg/renderPages.js +1 -1
  40. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  41. package/dist/node/ssg/ssgEnv.js +1 -1
  42. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  43. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  44. package/dist/node/ssg-md/remarkSplitMdx.d.ts +0 -4
  45. package/dist/node/ssg-md/remarkSplitMdx.js +266 -163
  46. package/dist/node/ssg-md/renderPage.js +1 -1
  47. package/dist/node/ssg-md/renderPages.js +1 -1
  48. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  49. package/dist/node/utils/checkLanguageParity.js +1 -1
  50. package/dist/node/utils/createHash.js +1 -1
  51. package/dist/node/utils/flattenMdxContent.js +1 -1
  52. package/dist/node/utils/getPageKey.js +1 -1
  53. package/dist/node/utils/reactAlias.js +1 -1
  54. package/dist/{tx~0.js → q~0.js} +3 -3
  55. package/dist/shiki-transformers.js +1 -1
  56. package/dist/theme/components/HomeFeature/index.css +10 -0
  57. package/dist/theme/components/Sidebar/SidebarGroup.css +14 -0
  58. package/dist/theme/components/Sidebar/SidebarGroup.js +29 -22
  59. package/dist/theme/components/Sidebar/SidebarItem.css +0 -10
  60. package/dist/theme/components/Sidebar/SidebarItem.js +2 -2
  61. package/dist/y~0.js +1 -1
  62. package/package.json +10 -7
  63. package/skills/rspress-best-practices/SKILL.md +82 -0
  64. package/skills/rspress-custom-theme/SKILL.md +242 -0
  65. package/skills/rspress-custom-theme/references/css-variables.md +177 -0
  66. package/skills/rspress-custom-theme/references/eject-components.md +154 -0
  67. package/skills/rspress-custom-theme/references/layout-slots.md +153 -0
  68. package/skills/rspress-description-generator/SKILL.md +118 -0
  69. package/skills/rspress-docs-generator/SKILL.md +60 -0
  70. package/skills/rspress-docs-generator/references/create-new-docs.md +73 -0
  71. package/skills/rspress-docs-generator/references/doc-structure-conventions.md +117 -0
  72. package/skills/rspress-docs-generator/references/maintain-docs-for-prs.md +31 -0
  73. package/skills/rspress-docs-generator/references/rspress-version-guard.md +13 -0
  74. package/dist/8~0.js +0 -3033
@@ -42,16 +42,6 @@
42
42
  outline-offset: -2px;
43
43
  }
44
44
 
45
- .rp-sidebar-item--group-item:before {
46
- content: "";
47
- background-color: var(--rp-c-divider-light);
48
- width: 1px;
49
- position: absolute;
50
- top: -2px;
51
- bottom: 0;
52
- left: -7px;
53
- }
54
-
55
45
  .rp-sidebar-item--group-item.rp-sidebar-item--active .rp-sidebar-item__left:before {
56
46
  content: "";
57
47
  background-color: var(--rp-c-brand);
@@ -57,7 +57,7 @@ function SidebarItemRaw({ active, text, icon, tag, link, context, className, lef
57
57
  'rp-sidebar-item--pending': isPending
58
58
  }, className),
59
59
  style: {
60
- marginLeft: 24 * depth
60
+ marginLeft: 20 * depth
61
61
  },
62
62
  'data-depth': depth,
63
63
  ...context ? {
@@ -72,7 +72,7 @@ function SidebarItemRaw({ active, text, icon, tag, link, context, className, lef
72
72
  'rp-sidebar-item--active': active
73
73
  }, className),
74
74
  style: {
75
- marginLeft: 24 * depth
75
+ marginLeft: 20 * depth
76
76
  },
77
77
  'data-depth': depth,
78
78
  ...context ? {
package/dist/y~0.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.1.4"
2
+ rE: "2.1.5"
3
3
  };
4
4
  function pMap(iterable, mapper, options) {
5
5
  return mapConcurrently(iterable, mapper, options, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -54,6 +54,7 @@
54
54
  "dist",
55
55
  "meta-json-schema.json",
56
56
  "nav-json-schema.json",
57
+ "skills",
57
58
  "static",
58
59
  "index.html"
59
60
  ],
@@ -62,27 +63,29 @@
62
63
  "@mdx-js/react": "^3.1.1",
63
64
  "@rsbuild/core": "^2.3.3",
64
65
  "@rsbuild/plugin-react": "~2.1.1",
65
- "@rspress/shared": "2.1.4",
66
+ "@rspress/shared": "2.1.5",
66
67
  "@shikijs/rehype": "^4.2.0",
67
68
  "@shikijs/transformers": "^4.2.0",
68
69
  "@types/mdast": "^4.0.4",
69
70
  "@types/react": "^19.3.0",
70
- "@unhead/react": "^2.1.17",
71
+ "@unhead/react": "^2.1.18",
71
72
  "body-scroll-lock": "4.0.0-beta.0",
72
73
  "clsx": "2.1.1",
73
74
  "copy-to-clipboard": "^3.3.3",
74
75
  "flexsearch": "0.8.212",
75
76
  "hast-util-heading-rank": "^3.0.0",
76
77
  "hast-util-to-jsx-runtime": "^2.3.7",
78
+ "mdast-util-gfm": "^3.1.0",
77
79
  "mdast-util-mdx": "^3.0.0",
78
80
  "mdast-util-mdxjs-esm": "^2.0.1",
81
+ "mdast-util-to-markdown": "^2.1.2",
79
82
  "medium-zoom": "1.1.2",
80
83
  "nprogress": "^0.2.0",
81
84
  "react": "^19.3.1",
82
85
  "react-dom": "^19.3.1",
83
86
  "react-lazy-with-preload": "^2.2.1",
84
- "react-render-to-markdown": "19.1.0",
85
- "react-router-dom": "^7.18.5",
87
+ "react-render-to-markdown": "19.2.0",
88
+ "react-router-dom": "^7.18.6",
86
89
  "rehype-external-links": "^3.0.0",
87
90
  "rehype-raw": "^7.0.0",
88
91
  "remark-cjk-friendly": "^2.3.4",
@@ -109,9 +112,9 @@
109
112
  "@types/nprogress": "^0.2.3",
110
113
  "@types/react-dom": "^19.3.0",
111
114
  "@types/web": "^0.0.367",
112
- "cac": "^7.1.0",
115
+ "cac": "^7.1.1",
113
116
  "execa": "8.0.1",
114
- "mdast-util-directive": "^3.1.1",
117
+ "mdast-util-directive": "^3.2.1",
115
118
  "mdast-util-mdx-expression": "^2.0.1",
116
119
  "memfs": "^4.80.1",
117
120
  "p-map": "^7.1.1",
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: rspress-best-practices
3
+ description: Configure, review, or troubleshoot Rspress v2 sites, including content conventions, navigation, MDX, assets, search, and deployment.
4
+ ---
5
+
6
+ # Rspress best practices
7
+
8
+ Apply these rules when writing or reviewing Rspress (v2) sites.
9
+
10
+ ## Configuration
11
+
12
+ - Use `rspress.config.ts` and `defineConfig` from `@rspress/core`
13
+ - Set `root` explicitly when docs are not under the default `docs/` directory
14
+ - Keep site-wide settings such as `title`, `description`, `icon`, `logo`, `base`, and `lang` in config instead of repeating them in page files
15
+ - Prefer first-class Rspress options before custom theme code or low-level bundler overrides
16
+ - Keep custom theme code in a top-level `theme/` directory and import original theme pieces from `@rspress/core/theme-original`
17
+
18
+ ## CLI
19
+
20
+ - Use `rspress dev` for local development
21
+ - Use `rspress build` for production output
22
+ - Use `rspress preview` only for local preview of the built site
23
+ - Use `rspress eject` only when CSS variables, class overrides, or layout wrapping cannot solve the customization
24
+
25
+ ## Docs structure and navigation
26
+
27
+ - Keep docs content under one clear docs root and group pages by topic or workflow, not by team ownership
28
+ - Use `_meta.json` or `_nav.json` to control sidebar and navigation labels/order instead of encoding order in filenames
29
+ - Put reusable MDX snippets or shared components in shared files instead of duplicating them across pages
30
+ - Keep landing pages concise and link to deeper task-oriented guides from them
31
+
32
+ ## Writing and frontmatter
33
+
34
+ - Add clear `title` and `description` frontmatter, and set `sidebar`, `outline`, `navbar`, or `footer` only when page defaults are not enough
35
+ - Use `pageType: home`, `doc`, `doc-wide`, `custom`, or `blank` intentionally based on layout needs
36
+ - Write task-first headings and short intros; avoid marketing-heavy copy in technical docs
37
+ - Prefer one topic per page and split overly long pages by workflow or feature area
38
+ - Keep code examples minimal, runnable, and version-accurate
39
+
40
+ ## MDX and components
41
+
42
+ - Use MDX for interactive docs and embedded components, but keep the main narrative understandable as plain markdown
43
+ - Prefer documented Rspress theme/runtime APIs over importing from internal source paths
44
+ - For app-wide UI or providers, use `globalUIComponents` or theme overrides instead of repeating imports in each page
45
+
46
+ ## Theme and styling
47
+
48
+ - Prefer CSS variables for brand colors, spacing, and surface styling
49
+ - Prefer BEM class overrides or `Layout` slots before ejecting built-in components
50
+ - In `theme/` files, keep `export * from '@rspress/core/theme-original'` unless intentionally replacing a named export
51
+ - Avoid full component ejection unless config, CSS, and wrapping cannot meet the requirement
52
+
53
+ ## I18n, Search, And AI
54
+
55
+ - For multilingual sites, organize locale content under per-language directories and keep navigation mirrored where practical
56
+ - Keep descriptions and other frontmatter text in the same language as the page content
57
+ - Configure search intentionally: use local search for small or medium sites, and hosted search when scale or cross-version indexing requires it
58
+ - Enable `llms` or `ssgMd` only when the site benefits from machine-readable outputs, and keep descriptions accurate because those outputs surface page summaries
59
+
60
+ ## Assets and public files
61
+
62
+ - Import source-managed images and components from docs/theme source when they belong to the content
63
+ - Use `public/` only for assets that must keep stable URL paths, such as favicons, social images, or download files
64
+ - Reference public assets by absolute site path and make sure they still work when `base` is set
65
+
66
+ ## Plugins and integration
67
+
68
+ - Prefer official Rspress plugins for search, preview, and API-doc scenarios before building custom solutions
69
+ - For component or library docs, use `@rspress/plugin-preview` and `@rspress/plugin-api-docgen` when interactive demos or API tables are needed
70
+ - Keep plugin usage explicit in config and remove unused plugins to reduce maintenance cost
71
+
72
+ ## Build, Deploy, And debugging
73
+
74
+ - Validate both `rspress dev` and `rspress build`; a page that works in dev can still fail during static generation
75
+ - Verify broken links, missing assets, and wrong `base` handling before deployment
76
+ - Keep generated output out of source control unless the hosting workflow explicitly requires committed artifacts
77
+ - When debugging content issues, inspect the resolved docs root, frontmatter, and theme overrides before assuming a bundler problem
78
+
79
+ ## Documentation
80
+
81
+ - For the latest Rspress docs, read https://rspress.rs/llms.txt
82
+ - Use the config and API docs when checking exact option names or current behavior
@@ -0,0 +1,242 @@
1
+ ---
2
+ name: rspress-custom-theme
3
+ description: Customize Rspress v2 themes with CSS variables, class overrides, Layout slots, icons, or component ejection.
4
+ ---
5
+
6
+ # Rspress custom theme
7
+
8
+ Guide for customizing Rspress (v2) themes. Rspress offers four levels of customization, from lightest to heaviest. Always prefer the lightest approach that meets the requirement — lighter approaches are more maintainable and survive Rspress upgrades.
9
+
10
+ ## Workflow
11
+
12
+ 1. **Understand the user's goal** — what do they want to change? (colors, layout, inject content, replace a component entirely?)
13
+ 2. **Pick the right level** using the decision flow below
14
+ 3. **Set up `theme/index.tsx`** if needed (Levels 1A, 3, 4 all need it)
15
+ 4. **Implement** following the patterns in this skill and reference files
16
+ 5. **Verify** the user's Rspress version is v2 (imports use `@rspress/core/*` not `rspress/*`)
17
+
18
+ ## Decision flow
19
+
20
+ | User wants to... | Level | Approach |
21
+ | ---------------------------------------------------------------- | ----- | --------------------------- |
22
+ | Change brand colors, fonts, spacing, shadows | 1 | CSS variables |
23
+ | Adjust a specific component's style (borders, padding, etc.) | 2 | BEM class overrides |
24
+ | Add content around existing components (banners, footers, logos) | 3 | Layout slots (wrap) |
25
+ | Override MDX rendering (custom `<h1>`, `<code>`, etc.) | 3 | `components` slot |
26
+ | Wrap the app in a provider (state, analytics, auth) | 4 | Eject `Root` |
27
+ | Replace built-in icons (logo, GitHub, search, etc.) | — | Icon re-export |
28
+ | Completely replace a built-in component | 4 | Eject that component |
29
+ | Add a global floating component (back-to-top, chat widget) | — | `globalUIComponents` config |
30
+ | Control page layout structure (hide sidebar, blank page) | — | Frontmatter `pageType` |
31
+
32
+ ---
33
+
34
+ ## theme/index.tsx — The entry point
35
+
36
+ Levels 1A, 3, and 4 all require a `theme/index.tsx` file in the project root (sibling to `docs/`). This is the single entry point for all theme customizations:
37
+
38
+ ```text
39
+ project/
40
+ ├── docs/
41
+ ├── theme/
42
+ │ ├── index.tsx # Theme entry — re-exports + overrides
43
+ │ ├── index.css # CSS variable / BEM overrides (optional)
44
+ │ └── components/ # Ejected components (Level 4)
45
+ └── rspress.config.ts
46
+ ```
47
+
48
+ Minimal setup:
49
+
50
+ ```tsx
51
+ // theme/index.tsx
52
+ import './index.css'; // optional
53
+ export * from '@rspress/core/theme-original';
54
+ ```
55
+
56
+ **Critical import rule**: Inside `theme/` files, always import from `@rspress/core/theme-original`. The path `@rspress/core/theme` resolves to your own `theme/index.tsx`, which causes circular imports. (In `docs/` MDX files, `@rspress/core/theme` is fine — it correctly points to your custom theme.)
57
+
58
+ ---
59
+
60
+ ## Level 1: CSS variables
61
+
62
+ Override CSS custom properties for brand colors, backgrounds, text, code blocks, and more.
63
+
64
+ **Option A** — `theme/index.css` (use when you also have component overrides in `theme/index.tsx`):
65
+
66
+ ```css
67
+ /* theme/index.css */
68
+ :root {
69
+ --rp-c-brand: #7c3aed;
70
+ --rp-c-brand-light: #8b5cf6;
71
+ --rp-c-brand-dark: #6d28d9;
72
+ }
73
+ .dark {
74
+ --rp-c-brand: #a78bfa;
75
+ }
76
+ ```
77
+
78
+ **Option B** — `globalStyles` (use when you only need CSS changes, no component overrides):
79
+
80
+ ```ts
81
+ // rspress.config.ts
82
+ export default defineConfig({
83
+ globalStyles: path.join(__dirname, 'styles/custom.css'),
84
+ });
85
+ ```
86
+
87
+ > **Full variable list**: Read `references/css-variables.md` for all available CSS variables with light/dark defaults.
88
+
89
+ ---
90
+
91
+ ## Level 2: BEM class overrides
92
+
93
+ All built-in components follow BEM naming: `.rp-[component]__[element]--[modifier]`.
94
+
95
+ Common targets: `.rp-nav`, `.rp-link`, `.rp-tabs`, `.rp-codeblock`, `.rp-codeblock__title`, `.rp-nav-menu__item--active`.
96
+
97
+ Use these in your CSS file for targeted style changes when CSS variables aren't granular enough.
98
+
99
+ ---
100
+
101
+ ## Level 3: wrap (Layout Slots)
102
+
103
+ Inject content at specific positions in the layout without replacing built-in components. Override `Layout` in `theme/index.tsx`:
104
+
105
+ ```tsx
106
+ // theme/index.tsx
107
+ import { Layout as OriginalLayout } from '@rspress/core/theme-original';
108
+ export * from '@rspress/core/theme-original';
109
+
110
+ export function Layout() {
111
+ return (
112
+ <OriginalLayout beforeNavTitle={<MyLogo />} bottom={<CustomFooter />} />
113
+ );
114
+ }
115
+ ```
116
+
117
+ Use runtime hooks inside slot components — import from `@rspress/core/runtime`: `useDark()`, `useLang()`, `useVersion()`, `usePage()`, `useSite()`, `useFrontmatter()`, `useI18n()`.
118
+
119
+ > **All slots & examples**: Read `references/layout-slots.md` for the complete slot list and usage patterns including i18n and MDX component overrides.
120
+
121
+ ---
122
+
123
+ ## Level 4: eject
124
+
125
+ Copy a built-in component's source for full replacement. Only use when wrap/slots cannot achieve the customization.
126
+
127
+ ```bash
128
+ rspress eject # list available components
129
+ rspress eject DocFooter # eject to theme/components/DocFooter/
130
+ ```
131
+
132
+ Then re-export in `theme/index.tsx` (named export takes precedence over the wildcard):
133
+
134
+ ```tsx
135
+ export * from '@rspress/core/theme-original';
136
+ export { DocFooter } from './components/DocFooter';
137
+ ```
138
+
139
+ > **Component list & patterns**: Read `references/eject-components.md` for available components, workflow, and common patterns.
140
+
141
+ ---
142
+
143
+ ## Custom icons
144
+
145
+ Rspress has 27 built-in icons used across the UI. You can replace any of them by re-exporting your own icon component with the same name — no ejection needed. This uses the same `theme/index.tsx` mechanism: your named export takes precedence over the wildcard re-export.
146
+
147
+ **Icon type**: Each icon is a React component or a URL string:
148
+
149
+ ```ts
150
+ import type { FC, SVGProps } from 'react';
151
+ type Icon = FC<SVGProps<SVGSVGElement>> | string;
152
+ ```
153
+
154
+ **Example 1** — Replace an icon with a custom SVG component:
155
+
156
+ ```tsx
157
+ // theme/index.tsx
158
+ export * from '@rspress/core/theme-original';
159
+
160
+ // Named export overrides the wildcard — replaces the GitHub icon site-wide
161
+ export const IconGithub = (props: React.SVGProps<SVGSVGElement>) => (
162
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" {...props}>
163
+ <path d="M12 2C6.477 2 2 6.484 2 12.017c0 ..." fill="currentColor" />
164
+ </svg>
165
+ );
166
+ ```
167
+
168
+ **Example 2** — Use an SVGR import:
169
+
170
+ ```tsx
171
+ // theme/index.tsx
172
+ export * from '@rspress/core/theme-original';
173
+
174
+ import CustomGithubIcon from './icons/github.svg?react';
175
+ export const IconGithub = CustomGithubIcon;
176
+ ```
177
+
178
+ **Using `SvgWrapper` in MDX or custom components**:
179
+
180
+ ```mdx
181
+ import { SvgWrapper, IconGithub } from '@rspress/core/theme';
182
+
183
+ <SvgWrapper icon={IconGithub} width={24} height={24} />
184
+ ```
185
+
186
+ **Available icons**: `IconArrowDown`, `IconArrowRight`, `IconClose`, `IconCopy`, `IconDeprecated`, `IconDown`, `IconEdit`, `IconEmpty`, `IconExperimental`, `IconExternalLink`, `IconFile`, `IconGithub`, `IconGitlab`, `IconHeader`, `IconJump`, `IconLink`, `IconLoading`, `IconMenu`, `IconMoon`, `IconScrollToTop`, `IconSearch`, `IconSmallMenu`, `IconSuccess`, `IconSun`, `IconTitle`, `IconWrap`, `IconWrapped`.
187
+
188
+ > **Source**: See the [icons source](https://github.com/web-infra-dev/rspress/blob/main/packages/core/src/theme/icons.ts) for default implementations.
189
+
190
+ ---
191
+
192
+ ## Global UI components
193
+
194
+ For components that should render on every page without theme overrides:
195
+
196
+ ```ts
197
+ // rspress.config.ts
198
+ export default defineConfig({
199
+ globalUIComponents: [
200
+ path.join(__dirname, 'components', 'BackToTop.tsx'),
201
+ [
202
+ path.join(__dirname, 'components', 'Analytics.tsx'),
203
+ { trackingId: '...' },
204
+ ],
205
+ ],
206
+ });
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Page types
212
+
213
+ Control layout per page via frontmatter `pageType`:
214
+
215
+ | Value | Description |
216
+ | ---------- | ------------------------------------- |
217
+ | `home` | Home page with navbar |
218
+ | `doc` | Standard doc with sidebar and outline |
219
+ | `doc-wide` | Doc without sidebar/outline |
220
+ | `custom` | Custom content with navbar only |
221
+ | `blank` | Custom content without navbar |
222
+ | `404` | 404 error page |
223
+
224
+ Fine-grained: set `navbar: false`, `sidebar: false`, `outline: false`, `footer: false` individually.
225
+
226
+ ---
227
+
228
+ ## Common pitfalls
229
+
230
+ - **Circular import**: Using `@rspress/core/theme` instead of `@rspress/core/theme-original` in `theme/` files — causes infinite loop.
231
+ - **Eject over-use**: Ejecting when a Layout slot or CSS variable would suffice — creates upgrade burden.
232
+ - **Missing re-export**: Forgetting `export * from '@rspress/core/theme-original'` in `theme/index.tsx` — breaks all un-overridden components.
233
+ - **v1 imports**: Using `rspress/theme` or `@rspress/theme-default` — these are v1 paths. v2 uses `@rspress/core/theme-original`.
234
+
235
+ ## Reference
236
+
237
+ - Custom theme guide: <https://rspress.rs/guide/basic/custom-theme>
238
+ - CSS variables: <https://rspress.rs/ui/vars>
239
+ - Layout component: <https://rspress.rs/ui/layout-components/layout>
240
+ - Built-in icons: <https://rspress.rs/ui/icons/>
241
+ - Built-in hooks: <https://rspress.rs/ui/hooks/>
242
+ - CLI commands (eject): <https://rspress.rs/api/commands>
@@ -0,0 +1,177 @@
1
+ # CSS variables reference
2
+
3
+ Complete list of CSS variables exposed by Rspress for theme customization.
4
+
5
+ - **Override location**: `theme/index.css` or `globalStyles` in `rspress.config.ts`
6
+ - **Dark mode selector**: `.dark { ... }`
7
+ - **Official docs**: <https://rspress.rs/ui/vars>
8
+
9
+ ---
10
+
11
+ ## Brand colors (shared)
12
+
13
+ ```css
14
+ :root {
15
+ --rp-c-brand: #0095ff;
16
+ --rp-c-brand-light: #33adff;
17
+ --rp-c-brand-lighter: #c6e0fd;
18
+ --rp-c-brand-dark: #0077ff;
19
+ --rp-c-brand-darker: #005fcc;
20
+ --rp-c-brand-tint: rgba(127, 163, 255, 0.16);
21
+ }
22
+ ```
23
+
24
+ ## Base variables
25
+
26
+ | Variable | Light | Dark |
27
+ | ---------------------- | --------------------- | ------------------------ |
28
+ | `--rp-c-bg` | `#ffffff` | `#121212` |
29
+ | `--rp-c-bg-soft` | `#f8f8f9` | `#292e37` |
30
+ | `--rp-c-bg-mute` | `#f1f1f1` | `#343a46` |
31
+ | `--rp-c-bg-alt` | `#fff` | `#000` |
32
+ | `--rp-c-divider` | `rgba(0, 0, 0, 0.25)` | `rgba(84, 84, 84, 0.65)` |
33
+ | `--rp-c-divider-light` | `rgba(0, 0, 0, 0.12)` | `rgba(84, 84, 84, 0.48)` |
34
+
35
+ ## Text colors
36
+
37
+ | Variable | Light | Dark |
38
+ | --------------- | ------------------------ | --------------------------- |
39
+ | `--rp-c-text-0` | `#000000` | `#ffffff` |
40
+ | `--rp-c-text-1` | `#242424` | `rgba(255, 255, 245, 0.93)` |
41
+ | `--rp-c-text-2` | `rgba(0, 0, 0, 0.7)` | `rgba(255, 255, 245, 0.65)` |
42
+ | `--rp-c-text-3` | `rgba(60, 60, 60, 0.33)` | `rgba(235, 235, 235, 0.38)` |
43
+ | `--rp-c-text-4` | `rgba(60, 60, 60, 0.18)` | `rgba(235, 235, 235, 0.18)` |
44
+ | `--rp-c-link` | `var(--rp-c-brand-dark)` | `var(--rp-c-brand-light)` |
45
+
46
+ ## Inline code
47
+
48
+ | Variable | Light | Dark |
49
+ | ------------------------- | --------------------------- | --------------------------- |
50
+ | `--rp-c-text-code` | `#476582` | `#c9def1` |
51
+ | `--rp-c-text-code-bg` | `rgba(153, 161, 179, 0.06)` | `rgba(255, 255, 255, 0.06)` |
52
+ | `--rp-c-text-code-border` | `rgba(0, 0, 0, 0.035)` | `rgba(255, 255, 255, 0.04)` |
53
+
54
+ ## Code blocks
55
+
56
+ | Variable | Light | Dark |
57
+ | ------------------------ | ------------------------------------- | ------------------------------------- |
58
+ | `--rp-code-font-size` | `0.875rem` | `0.875rem` |
59
+ | `--rp-code-title-bg` | `#f8f8f9` | `#191919` |
60
+ | `--rp-code-block-color` | `rgb(46, 52, 64)` | `rgb(229, 231, 235)` |
61
+ | `--rp-code-block-bg` | `var(--rp-c-bg)` | `var(--rp-c-bg)` |
62
+ | `--rp-code-block-border` | `1px solid var(--rp-c-divider-light)` | `1px solid var(--rp-c-divider-light)` |
63
+ | `--rp-code-block-shadow` | `none` | `none` |
64
+
65
+ ## Shiki syntax highlighting
66
+
67
+ Rspress uses `.dark` on `html` as the public dark-mode toggle for general theme overrides. The Shiki token blocks below target `html:not(.rp-dark)` and `html.rp-dark`, which Rspress uses internally for syntax highlighting variables.
68
+
69
+ ### Light
70
+
71
+ ```css
72
+ html:not(.rp-dark) {
73
+ --shiki-foreground: inherit;
74
+ --shiki-background: transparent;
75
+ --shiki-token-constant: #1976d2;
76
+ --shiki-token-string: #31a94d;
77
+ --shiki-token-comment: rgb(182, 180, 180);
78
+ --shiki-token-keyword: #cf2727;
79
+ --shiki-token-parameter: #f59403;
80
+ --shiki-token-function: #7041c8;
81
+ --shiki-token-string-expression: #218438;
82
+ --shiki-token-punctuation: #242323;
83
+ --shiki-token-link: #22863a;
84
+ --shiki-token-deleted: #d32828;
85
+ --shiki-token-inserted: #22863a;
86
+ }
87
+ ```
88
+
89
+ ### Dark
90
+
91
+ ```css
92
+ html.rp-dark {
93
+ --shiki-foreground: inherit;
94
+ --shiki-background: transparent;
95
+ --shiki-token-constant: #6fb0fa;
96
+ --shiki-token-string: #f9a86e;
97
+ --shiki-token-comment: #6a727b;
98
+ --shiki-token-keyword: #f47481;
99
+ --shiki-token-parameter: #ff9800;
100
+ --shiki-token-function: #ae8eeb;
101
+ --shiki-token-string-expression: #4fb74d;
102
+ --shiki-token-punctuation: #bbbbbb;
103
+ --shiki-token-link: #f9a76d;
104
+ --shiki-token-deleted: #ee6d7a;
105
+ --shiki-token-inserted: #36c47f;
106
+ }
107
+ ```
108
+
109
+ ## Grays (shared)
110
+
111
+ ```css
112
+ :root {
113
+ --rp-c-gray: #8e8e8e;
114
+ --rp-c-gray-light-1: #aeaeae;
115
+ --rp-c-gray-light-2: #c7c7c7;
116
+ --rp-c-gray-light-3: #d1d1d1;
117
+ --rp-c-gray-light-4: #e5e5e5;
118
+ --rp-c-gray-light-5: #f2f2f2;
119
+ }
120
+ ```
121
+
122
+ ## Shadows (shared)
123
+
124
+ ```css
125
+ :root {
126
+ --rp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.02), 0 1px 0 rgba(0, 0, 0, 0.06);
127
+ --rp-shadow-2: 0 3px 12px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.07);
128
+ --rp-shadow-3: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
129
+ --rp-shadow-4: 0 14px 44px rgba(0, 0, 0, 0.12), 0 3px 9px rgba(0, 0, 0, 0.12);
130
+ --rp-shadow-5:
131
+ 0 18px 56px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.16);
132
+ }
133
+ ```
134
+
135
+ ## Radius (shared)
136
+
137
+ ```css
138
+ :root {
139
+ --rp-radius: 1rem;
140
+ --rp-radius-small: 0.5rem;
141
+ --rp-radius-large: 1.5rem;
142
+ }
143
+ ```
144
+
145
+ ## Home page
146
+
147
+ Note: `...` in gradient values marks omitted gradient parameters, not literal CSS. See the official docs link above for complete values.
148
+
149
+ | Variable | Light | Dark |
150
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
151
+ | `--rp-home-hero-secondary-color` | `#a673ff` | `#a673ff` |
152
+ | `--rp-home-hero-title-color` | `transparent` | `transparent` |
153
+ | `--rp-home-hero-title-bg` | `linear-gradient(90deg, var(--rp-c-brand-dark) 0%, var(--rp-c-brand-dark) 30%, var(--rp-home-hero-secondary-color) 100%)` | (same) |
154
+ | `--rp-home-background-bg` | `radial-gradient(...), radial-gradient(...), radial-gradient(...), #fff` | `radial-gradient(...), radial-gradient(...), radial-gradient(...), #121212` |
155
+ | `--rp-home-feature-bg` | `linear-gradient(135deg, #fff, #f9f9f980)` | `linear-gradient(135deg, #ffffff00, #ffffff08)` |
156
+
157
+ ## Quick start
158
+
159
+ ```css
160
+ /* Example brand color overrides for the custom theme scaffold. */
161
+ /* For more CSS variables, see https://rspress.rs/ui/vars. */
162
+ :root {
163
+ --rp-c-brand: #ff5e00;
164
+ --rp-c-brand-dark: #ff704d;
165
+ --rp-c-brand-darker: #ff704d;
166
+ --rp-c-brand-light: #ff7524;
167
+ --rp-c-brand-lighter: #ff7524;
168
+ --rp-c-brand-tint: rgba(255, 94, 0, 0.07);
169
+
170
+ --rp-home-hero-secondary-color: #ff5e00;
171
+ }
172
+
173
+ .dark {
174
+ --rp-c-brand: #ff8c4d;
175
+ --rp-home-hero-secondary-color: #ff8c4d;
176
+ }
177
+ ```