Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Diff

on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [main]

jobs:
Build:
runs-on: ubuntu-latest

permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Pnpm
run: |
npm install -g corepack@latest --force
corepack enable

- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22
cache: 'pnpm'

- name: Install Dependencies and Build
run: |
pnpm install

- name: Build Demo Project
run: |
cd website
pnpm install
RSDOCTOR=1 pnpm run build

- name: Report Compressed Size
uses: web-infra-dev/rsdoctor-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
file_path: 'website/doc_build/web/rsdoctor-data.json'
target_branch: 'main'
70 changes: 70 additions & 0 deletions .github/workflows/ecosystem-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Ecosystem CI

on:
push:
branches: ['main']
workflow_dispatch:
inputs:
branch:
description: 'The branch of the Ecosystem CI run'
required: true
default: 'main'

permissions:
contents: write
issues: write
pull-requests: write

jobs:
changes:
runs-on: ubuntu-latest
if: github.repository == 'web-infra-dev/rspress' && github.event_name != 'workflow_dispatch'
outputs:
changed: ${{ steps.changes.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
with:
fetch-depth: 1

- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
predicate-quantifier: 'every'
filters: |
changed:
- "!**/*.md"
- "!**/*.mdx"
- "!**/_meta.json"
- "!**/dictionary.txt"
- "!document/**"

ecosystem_ci_dispatch:
name: Dispatch ecosystem CI
runs-on: ubuntu-latest
if: github.repository == 'web-infra-dev/rspress' && github.event_name == 'workflow_dispatch'
steps:
- name: Trigger Ecosystem CI
uses: rspack-contrib/rstack-ecosystem-ci/.github/actions/ecosystem_ci_dispatch@main
with:
github-token: ${{ secrets.REPO_rspress_ECO_CI_GITHUB_TOKEN_NEXT }}
ecosystem-owner: web-infra-dev
ecosystem-repo: rspress
workflow-file: rspress-ecosystem-ci-selected.yml
client-payload: '{"ref":"${{ github.event.inputs.branch }}","repo":"web-infra-dev/rspress","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
branch: ${{ github.event.inputs.branch }}

ecosystem_ci_per_commit:
name: Run ecosystem CI per commit
needs: changes
runs-on: ubuntu-latest
if: github.repository == 'web-infra-dev/rspress' && github.event_name != 'workflow_dispatch' && needs.changes.outputs.changed == 'true'
steps:
- name: Trigger Ecosystem CI
uses: rspack-contrib/rstack-ecosystem-ci/.github/actions/ecosystem_ci_per_commit@main
with:
github-token: ${{ secrets.REPO_RSPRESS_ECO_CI_GITHUB_TOKEN_NEXT }}
ecosystem-owner: web-infra-dev
ecosystem-repo: rspress
workflow-file: rspress-ecosystem-ci-from-commit.yml
client-payload: '{"commitSHA":"${{ github.sha }}","updateComment":true,"repo":"web-infra-dev/rspress","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
6 changes: 3 additions & 3 deletions e2e/fixtures/tabs-component/doc/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { Tabs, Tab } from '@rspress/core/theme';

## Tab a

<Tabs tabContainerClassName="tabs-a">
<Tabs className="tabs-a">
<Tab label="label1">content1</Tab>
</Tabs>

## Tab b

<Tabs tabContainerClassName="tabs-b">
<Tabs className="tabs-b">
<Tab label="label2">content2</Tab>
<Tab label="label3">content3</Tab>
<Tab label="label4">content4</Tab>
</Tabs>

## Tab c

<Tabs tabContainerClassName="tabs-c"></Tabs>
<Tabs className="tabs-c"></Tabs>
7 changes: 7 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"./shiki-transformers": {
"types": "./dist/shiki-transformers.d.ts",
"default": "./dist/shiki-transformers.js"
},
"./_private/react": {
"default": "./dist/_private/react/index.js"
}
},
"main": "./dist/index.js",
Expand Down Expand Up @@ -81,17 +84,20 @@
"hast-util-to-jsx-runtime": "^2.3.6",
"html-to-text": "^9.0.5",
"lodash-es": "^4.17.21",
"mdast-util-mdx": "^3.0.0",
"mdast-util-mdxjs-esm": "^2.0.1",
"medium-zoom": "1.1.0",
"nprogress": "^0.2.0",
"picocolors": "^1.1.1",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-lazy-with-preload": "^2.2.1",
"react-reconciler": "0.33.0",
"react-router-dom": "^6.30.1",
"rehype-external-links": "^3.0.0",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",
"remark-mdx": "^3.1.1",
"scroll-into-view-if-needed": "^3.1.0",
"shiki": "^3.12.2",
"tinyglobby": "^0.2.15",
Expand All @@ -115,6 +121,7 @@
"@types/nprogress": "^0.2.3",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@types/react-reconciler": "^0.32.1",
"@types/web": "^0.0.288",
"execa": "8.0.1",
"mdast-util-directive": "^3.1.0",
Expand Down
17 changes: 16 additions & 1 deletion packages/core/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'node:path';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginSass } from '@rsbuild/plugin-sass';
import { pluginSvgr } from '@rsbuild/plugin-svgr';
Expand All @@ -22,6 +21,22 @@ const COMMON_EXTERNALS = [
export default defineConfig({
plugins: [pluginPublint()],
lib: [
{
bundle: false,
dts: false,
format: 'esm',
syntax: 'es2022',
source: {
entry: {
index: './src/node/ssg-md/react/*.ts',
},
},
output: {
distPath: {
root: './dist/_private/react',
},
},
},
{
format: 'esm',
syntax: 'es2022',
Expand Down
22 changes: 17 additions & 5 deletions packages/core/src/node/PluginDriver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type {
PageIndexInfo,
RouteMeta,
RspressPlugin,
UserConfig,
import {
addLeadingSlash,
addTrailingSlash,
type PageIndexInfo,
type RouteMeta,
type RspressPlugin,
type UserConfig,
} from '@rspress/shared';
import { haveNavSidebarConfig } from './auto-nav-sidebar';
import type { RouteService } from './route/RouteService';
Expand Down Expand Up @@ -108,7 +110,17 @@ export class PluginDriver {
}
}

private async normalizeConfig() {
this.#config.ssg ??= true;
this.#config.llms ??= false;
this.#config.base = addTrailingSlash(
addLeadingSlash(this.#config.base ?? '/'),
);
}

async modifyConfig() {
this.normalizeConfig();

let config = this.#config;

for (let i = 0; i < this.#plugins.length; i++) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/node/auto-nav-sidebar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function extractInfoFromFrontmatterWithAbsolutePath(
overviewHeaders: number[] | undefined;
context: string | undefined;
tag: string | undefined;
description: string | undefined;
}> {
const fileHandle = await fs.open(absolutePath, 'r');
try {
Expand Down Expand Up @@ -112,6 +113,7 @@ export async function extractInfoFromFrontmatterWithAbsolutePath(
overviewHeaders: frontmatter.overviewHeaders,
context: frontmatter.context,
tag: frontmatter.tag,
description: frontmatter.description,
};
} finally {
await fileHandle.close();
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export async function build(options: BuildOptions) {
// 1. create PluginDriver
const pluginDriver = await PluginDriver.create(config, configFilePath, true);
const modifiedConfig = await pluginDriver.modifyConfig();
const ssgConfig = Boolean(modifiedConfig.ssg ?? true);
const enableSSG = Boolean(
(modifiedConfig.ssg || modifiedConfig.llms) ?? true,
);

// 2. create RouteService
const additionalPages = await pluginDriver.addPages();
Expand All @@ -42,15 +44,15 @@ export async function build(options: BuildOptions) {
modifiedConfig,
pluginDriver,
routeService,
ssgConfig,
enableSSG,
);
await rsbuild.build();
} finally {
await checkLanguageParity(config);
}
await pluginDriver.afterBuild();

if (!ssgConfig) {
if (!enableSSG) {
hintSSGFalse();
}
}
10 changes: 10 additions & 0 deletions packages/core/src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export const SSR_SERVER_ENTRY = path.join(
'ssrServerEntry.js',
);

export const SSG_MD_SERVER_ENTRY = path.join(
PACKAGE_ROOT,
'dist',
'runtime',
'ssrMdServerEntry.js',
);

export const OUTPUT_DIR = 'doc_build';

export const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
Expand All @@ -65,3 +72,6 @@ export const PUBLIC_DIR = 'public';
// Prevent the risk of naming conflicts with the user's folders
export const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
export const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';

export const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
export const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
Loading
Loading