Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@alauda/doom": "0.23.5"
},
"changesets": []
}
5 changes: 5 additions & 0 deletions .changeset/rotten-cows-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/doom": major
---

feat!: migrate to rspress v2
43 changes: 22 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,26 @@
"version": "changeset version && yarn --no-immutable"
},
"dependencies": {
"@cspell/eslint-plugin": "^9.0.1",
"@cspell/eslint-plugin": "^9.0.2",
"@eslint-react/eslint-plugin": "^1.49.0",
"@inquirer/prompts": "^7.5.1",
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
"@playwright/browser-chromium": "^1.52.0",
"@rsbuild/plugin-sass": "^1.3.1",
"@rsbuild/plugin-yaml": "^1.0.2",
"@rspress/core": "1.44.0",
"@rspress/core": "2.0.0-beta.6",
"@shikijs/transformers": "^3.4.2",
"chokidar": "^4.0.3",
"cli-progress": "^3.12.0",
"clsx": "^2.1.1",
"commander": "^13.1.0",
"commander": "^14.0.0",
"ejs": "^3.1.10",
"es-toolkit": "^1.37.2",
"eslint": "^9.26.0",
"es-toolkit": "^1.38.0",
"eslint": "^9.27.0",
"eslint-plugin-mdx": "^3.4.2",
"html-tag-names": "^2.1.0",
"mdast-util-mdx": "^2.0.1",
"mdast-util-mdx-jsx": "^2.1.4",
"mdast-util-mdx": "^3.0.0",
"mdast-util-mdx-jsx": "^3.2.0",
"mermaid": "^11.6.0",
"openai": "^5.0.0-beta.0",
"openapi-types": "^12.1.3",
Expand All @@ -83,13 +84,13 @@
"pdf-merger-js": "^5.1.2",
"picomatch": "^4.0.2",
"playwright": "^1.52.0",
"react-markdown": "^8.0.7",
"rehype-raw": "^6.1.1",
"remark-directive": "^2.0.1",
"remark-frontmatter": "^4.0.1",
"remark-gfm": "^3.0.1",
"remark-mdx": "^2.3.0",
"remark-stringify": "^10.0.3",
"react-markdown": "^10.1.0",
"rehype-raw": "^7.0.0",
"remark-directive": "^4.0.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.1",
"remark-mdx": "^3.1.0",
"remark-stringify": "^11.0.0",
"shiki": "^3.4.2",
"simple-git": "^3.27.0",
"swagger2openapi": "^7.0.8",
Expand All @@ -103,23 +104,23 @@
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.4",
"@eslint/js": "^9.26.0",
"@eslint/js": "^9.27.0",
"@swc-node/register": "^1.10.10",
"@swc/core": "1.11.24",
"@total-typescript/ts-reset": "^0.6.1",
"@types/cli-progress": "^3.11.6",
"@types/ejs": "^3.1.5",
"@types/node": "^18.19.100",
"@types/node": "^22.15.21",
"@types/picomatch": "^4.0.0",
"@types/react": "^18.3.21",
"@types/react-dom": "^18.3.7",
"@types/react": "^19.1.4",
"@types/react-dom": "^19.1.5",
"@types/swagger2openapi": "^7.0.4",
"@unts/patch-package": "^8.1.1",
"clean-pkg-json": "^1.3.0",
"eslint-import-resolver-typescript": "^4.3.4",
"eslint-plugin-import-x": "^4.11.1",
"eslint-import-resolver-typescript": "^4.3.5",
"eslint-plugin-import-x": "^4.12.2",
"nano-staged": "^0.8.0",
"npm-run-all2": "^7.0.2",
"npm-run-all2": "^8.0.3",
"prettier": "^3.5.3",
"prettier-plugin-pkg": "^0.19.1",
"prettier-plugin-properties": "^0.3.0",
Expand Down
54 changes: 0 additions & 54 deletions patches/unist-util-visit-parents+5.1.3.patch

This file was deleted.

1 change: 0 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ program
const runBuild = () =>
build({
config,
appDirectory: CWD,
docDirectory,
})

Expand Down
56 changes: 18 additions & 38 deletions src/cli/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'node:fs/promises'
import path from 'node:path'

import { nodeTypes } from '@mdx-js/mdx'
import { pluginSass } from '@rsbuild/plugin-sass'
import { pluginYaml } from '@rsbuild/plugin-yaml'
import {
addLeadingSlash,
Expand Down Expand Up @@ -36,7 +37,6 @@ import {
mermaidPlugin,
permissionPlugin,
replacePlugin,
shikiPlugin,
} from '../plugins/index.js'
import {
isExplicitlyUnversioned,
Expand Down Expand Up @@ -225,12 +225,23 @@ const getCommonConfig = async ({
},
markdown: {
checkDeadLinks: true,
highlightLanguages: [['jsonc', 'json']],
mdxRs: false,
rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
},
ssg: {
strict: true,
shiki: {
transformers: [
// builtin transformers
transformerMetaHighlight(),
transformerMetaWordHighlight(),
transformerNotationDiff(),
transformerNotationErrorLevel(),
transformerNotationFocus(),
transformerNotationHighlight(),
transformerNotationWordHighlight(),
transformerRemoveNotationEscape(),

// custom transformers
createTransformerCallouts(),
],
},
},
themeConfig: {
enableScrollToTop: true,
Expand Down Expand Up @@ -263,43 +274,12 @@ const getCommonConfig = async ({
localBasePath,
force,
}),
shikiPlugin({
theme: config.shiki?.theme,
langs: [
'dockerfile',
'dotenv',
'html',
'go',
'jsonc',
'mermaid',
'java',
'python',
'toml',
...(config.shiki?.langs ?? []),
],
transformers: [
// builtin transformers
transformerMetaHighlight(),
transformerMetaWordHighlight(),
transformerNotationDiff(),
transformerNotationErrorLevel(),
transformerNotationFocus(),
transformerNotationHighlight(),
transformerNotationWordHighlight(),
transformerRemoveNotationEscape(),

// custom transformers
createTransformerCallouts(),

...(config.shiki?.transformers ?? []),
],
}),
],
builderConfig: {
dev: {
lazyCompilation: lazy,
},
plugins: [pluginYaml()],
plugins: [pluginSass(), pluginYaml()],
server: {
open,
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/auto-toc/remark-auto-toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const remarkAutoToc: Plugin<[], Root> = function () {
{
type: 'mdxJsxAttribute',
name: 'className',
value: 'doom-auto-toc',
value: 'doom-auto-toc rspress-toc-exclude',
},
],
children: [
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/replace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ export * from './normalize-img-src.js'
export type * from './types.js'
export * from './utils.js'

declare module 'unified' {
interface Data {
pageMeta: Record<string, unknown>
}
}

declare module 'mdast' {
interface Data {
_mdxExplicitJsx?: boolean
}
}

export const replacePlugin = ({
lang,
localBasePath,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/replace/normalize-img-src.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path'

import { isExternalUrl, removeLeadingSlash } from '@rspress/core'
import { cloneDeep } from 'es-toolkit'
import type { Content } from 'mdast'
import type { RootContent } from 'mdast'
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'
import { visit } from 'unist-util-visit'

Expand All @@ -25,7 +25,7 @@ export interface NormalizeImgSrcOptions {
}

export const normalizeImgSrc = (
content: Content,
content: RootContent,
{
refSource,
localPublicBase,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/replace/rehype-normalize-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const rehypeNormalizeLink: Plugin<[], Root> = () => {
return
}

const { alt, src } = node.properties || {}
const { alt, src } = node.properties

if (typeof src !== 'string') {
return
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/replace/remark-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path'

import { isProduction } from '@rspress/core'
import { logger } from '@rspress/shared/logger'
import type { Content, Root } from 'mdast'
import type { Root, RootContent } from 'mdast'
import type { Plugin } from 'unified'
import { parse, stringify } from 'yaml'
import { cyan, red } from 'yoctocolors'
Expand Down Expand Up @@ -77,7 +77,7 @@ export const remarkReplace: Plugin<
frontmatterNode &&
(parse(frontmatterNode.value) as Record<string, unknown> | null)

const newContentChildren: Array<Content | Content[]> = []
const newContentChildren: Array<RootContent | RootContent[]> = []

let start = false
let refName = ''
Expand Down Expand Up @@ -231,7 +231,7 @@ export const remarkReplace: Plugin<
}
}

const newAstChildren: Array<Content | Content[]> = []
const newAstChildren: Array<RootContent | RootContent[]> = []

const currLang = lang === null ? 'zh' : relativePath.split(/[\\/]/)[0]

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/replace/resolve-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'node:path'
import { isProduction } from '@rspress/core'
import { logger } from '@rspress/shared/logger'
import { render } from 'ejs'
import type { Content } from 'mdast'
import type { RootContent } from 'mdast'
import { red } from 'yoctocolors'

import { resolveRepo } from '../../utils/index.js'
Expand All @@ -16,7 +16,7 @@ import { getFrontmatterNode, mdProcessor, mdxProcessor } from './utils.js'
export interface ResolveReferenceResult {
publicBase: string
sourceBase: string
contents: Content[]
contents: RootContent[]
}

const refCache = new Map<string, Promise<ResolveReferenceResult | undefined>>()
Expand Down Expand Up @@ -118,7 +118,7 @@ const resolveReference_ = async (
return
}

const nodes: Content[] = frontmatterNode ? [frontmatterNode] : []
const nodes: RootContent[] = frontmatterNode ? [frontmatterNode] : []

for (let i = active.index, n = root.children.length; i < n; i++) {
if (i === active.index && (source.ignoreHeading ?? active.depth === 1)) {
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/replace/resolve-release.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { logger } from '@rspress/shared/logger'
import { render } from 'ejs'
import type { Content, List, ListItem, Paragraph, PhrasingContent } from 'mdast'
import type {
List,
ListItem,
Paragraph,
PhrasingContent,
RootContent,
} from 'mdast'
import { ResponseError, xfetch } from 'x-fetch'
import { cyan, red } from 'yoctocolors'

Expand All @@ -9,7 +15,7 @@ import { isCI } from './utils.js'

const releaseCache = new Map<
string,
Promise<Record<string, Content | Content[]> | undefined>
Promise<Record<string, RootContent | RootContent[]> | undefined>
>()

const FIELD_MAPPER: Record<JiraLanguage, string> = {
Expand Down
Loading