web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.16k stars 103 forks source link

[Feature]: Reusable theme scalability support #901

Open linbudu599 opened 1 month ago

linbudu599 commented 1 month ago

What problem does this feature solve?

Currently (from the documentation) rspress only supports extensions that create theme folders in the current directory, and does not support loading theme extensions from npm packages, which prevents the community from sharing theme packages such as rspress-theme-xxx for the rspress ecosystem.

What does the proposed API look like?

The intended API should consist of two parts:

import * as path from 'path';
import { defineConfig } from 'rspress/config';

export default defineConfig({
  root: path.join(__dirname, 'docs'),
  theme: 'rspress-theme-blog',
  // should support extending types from theme package
  themeConfig: { },
});

Some additional things: Themes should normally be a superset of plugins, so plugins in the theme should also be able to be loaded properly.

sanyuan0704 commented 1 month ago

Nice features! That's what we are going to support. Thanks your feedback. We will design the theme npm package exports and support loading theme package in this month.

Timeless0911 commented 2 weeks ago

It's a big feature and we should also implement theme inheritance like https://vuepress.vuejs.org/theme/inheritance.html#theme-inheritance do.

May be it will be implemented in 2.0 refactor?