Skip to content

feat(theme)!: custom theme should use @rspress/core/theme-original#2860

Merged
SoonIter merged 7 commits intomainfrom
syt/theme-default-2
Dec 8, 2025
Merged

feat(theme)!: custom theme should use @rspress/core/theme-original#2860
SoonIter merged 7 commits intomainfrom
syt/theme-default-2

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Dec 8, 2025

Summary

For @rspress/core/theme-original or @theme-original

Before

In Rspress V1 document, @theme is the alias for rspress/theme.

but @theme is an alias which points to theme/index.tsx and falls back to rspress/theme

rspress/theme or @rspress/core/theme points to Rspress's theme-default, they are actually different things.

After

We standardize this behavior, which is the same as docusaurus.

  1. In docs directory, @theme or @rspress/core/theme should be used, which points to theme/index.tsx and falls back to theme-default

  2. In theme directory , @theme-original or @rspress/core/theme-original should be used, which always points to Rspress's theme-default

For @theme-assets

Before

We have a separate entry for exporting @theme-assets

import { SvgWrapper } from '@theme'
import SearchSvg from '@theme-assets/Search';

<SvgWrapper icon={SearchSvg} />

After

@theme-assets has been removed. Icons are exported from @theme and prefixed with Icon, for example: IconSearch

import { SvgWrapper, IconSearch } from '@theme';

<SvgWrapper icon={IconSearch} />
                   ^? type Icon = React.FC<React.SVGProps<SVGSVGElement>> | string;

Related Issue

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings December 8, 2025 06:37
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 8, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit cf3b81d
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/6936783f19b2ee0008ba9366
😎 Deploy Preview https://deploy-preview-2860--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 8, 2025

Rsdoctor Bundle Diff Analysis

📁 web

Path: website/doc_build/web/rsdoctor-data.json

📌 Baseline Commit: d0c2059851 | PR: #2856

Metric Current Baseline Change
📊 Total Size 14.5 MB 14.5 MB 140.0 B (0.0%)
📄 JavaScript 13.9 MB 13.9 MB 32.0 B (0.0%)
🎨 CSS 113.7 KB 113.7 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 501.4 KB 501.3 KB 108.0 B (0.0%)

📦 Download Diff Report: web Bundle Diff

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the theme import pattern in Rspress to align with Docusaurus conventions, introducing a clear distinction between @rspress/core/theme (user's custom theme with fallback to default) and @rspress/core/theme-original (always points to Rspress's default theme).

Key Changes:

  • Introduces @rspress/core/theme-original alias for accessing the default theme from custom theme files
  • Refactors icon imports from @theme-assets/* pattern to named exports from the theme package
  • Updates all documentation and examples to use the new import patterns
  • Adds plugin support for custom theme directories via themeDir hook

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
website/theme/index.tsx Updated to import from @rspress/core/theme-original instead of @rspress/core/theme
website/docs/zh/ui/custom-theme.mdx Updated Chinese documentation with new import patterns
website/docs/en/ui/custom-theme.mdx Updated English documentation with new import patterns
website/docs/zh/fragments/builtin-components.mdx Replaced @theme-assets imports with exported icon components
website/docs/en/fragments/builtin-components.mdx Replaced @theme-assets imports with exported icon components
packages/shared/src/types/index.ts Updated comment for themeDir config property
packages/shared/src/types/Plugin.ts Added themeDir plugin hook definition
packages/core/src/theme/index.ts Added icon exports and cleaned up comment formatting
packages/core/src/theme/icons.ts New file exporting all theme icons as named exports
packages/core/src/theme/env.d.ts Removed @theme-assets/* module declaration
packages/core/src/theme/components/*.tsx Refactored all components to use named icon imports instead of @theme-assets
packages/core/src/node/utils/detectCustomIcon.ts Removed deprecated custom icon detection utility
packages/core/src/node/logger/hint.ts Updated breaking change detection and migration hints
packages/core/src/node/initRsbuild.ts Updated alias configuration to support new theme import patterns
packages/core/src/node/PluginDriver.ts Added themeDir method to support plugin-provided themes
packages/core/package.json Added ./theme-original export path
e2e/fixtures//theme/.tsx Updated test fixtures to use new import patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/theme/components/Search/SuggestItem.tsx
Comment thread packages/core/src/node/initRsbuild.ts Outdated
Comment thread packages/core/src/node/logger/hint.ts
Comment thread packages/core/src/theme/components/Search/SearchPanel.tsx Outdated
Comment thread packages/core/src/node/PluginDriver.ts Outdated
@SoonIter SoonIter requested a review from Timeless0911 December 8, 2025 07:17
@SoonIter
Copy link
Copy Markdown
Member Author

SoonIter commented Dec 8, 2025

@SoonIter SoonIter merged commit 8a60a92 into main Dec 8, 2025
9 checks passed
@SoonIter SoonIter deleted the syt/theme-default-2 branch December 8, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants