@alauda/doom 0.14.21 → 0.15.1
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.
- package/lib/cli/index.js +1 -0
- package/lib/cli/load-config.d.ts +1 -1
- package/lib/cli/load-config.js +17 -4
- package/lib/plugins/shiki/rehypePlugin.js +22 -7
- package/lib/types.d.ts +3 -1
- package/package.json +6 -5
- package/styles/global.scss +12 -0
- package/styles/overview.module.scss +5 -0
package/lib/cli/index.js
CHANGED
|
@@ -35,6 +35,7 @@ program
|
|
|
35
35
|
2. translate ignore hash equality check and original text`, (value) => !!value && value !== 'false', false)
|
|
36
36
|
.option('-i, --ignore [boolean]', 'Ignore internal routes', (value) => !!value && value !== 'false', false)
|
|
37
37
|
.option('-d, --download [boolean]', 'Display download pdf link on nav bar', (value) => !!value && value !== 'false', false)
|
|
38
|
+
.option('--no-open [boolean]', 'Do not open the browser after starting the server')
|
|
38
39
|
.command('dev', { isDefault: true })
|
|
39
40
|
.description('Start the development server')
|
|
40
41
|
.argument('[root]', 'Root directory of the documentation')
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UserConfig } from '@rspress/core';
|
|
2
2
|
import type { GlobalCliOptions } from '../types.js';
|
|
3
|
-
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, ignore, force, }?: GlobalCliOptions): Promise<{
|
|
3
|
+
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, ignore, force, open, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
filepath?: string;
|
|
6
6
|
}>;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -19,7 +19,7 @@ const zhLocaleConfig = {
|
|
|
19
19
|
prevPageText: '上一页',
|
|
20
20
|
nextPageText: '下一页',
|
|
21
21
|
};
|
|
22
|
-
const getCommonConfig = ({ config, root, configFilePath, base, version, download, ignore, force, }) => {
|
|
22
|
+
const getCommonConfig = ({ config, root, configFilePath, base, version, download, ignore, force, open, }) => {
|
|
23
23
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
24
24
|
root = resolveDocRoot(CWD, root, config.root);
|
|
25
25
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
@@ -84,7 +84,18 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
84
84
|
force,
|
|
85
85
|
}),
|
|
86
86
|
shikiPlugin({
|
|
87
|
-
|
|
87
|
+
theme: config.shiki?.theme,
|
|
88
|
+
langs: [
|
|
89
|
+
'dockerfile',
|
|
90
|
+
'dotenv',
|
|
91
|
+
'html',
|
|
92
|
+
'go',
|
|
93
|
+
'jsonc',
|
|
94
|
+
'mermaid',
|
|
95
|
+
'java',
|
|
96
|
+
'python',
|
|
97
|
+
...(config.shiki?.langs ?? []),
|
|
98
|
+
],
|
|
88
99
|
transformers: [
|
|
89
100
|
// builtin transformers
|
|
90
101
|
transformerMetaHighlight(),
|
|
@@ -97,13 +108,14 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
97
108
|
transformerRemoveNotationEscape(),
|
|
98
109
|
// custom transformers
|
|
99
110
|
createTransformerCallouts(),
|
|
111
|
+
...(config.shiki?.transformers ?? []),
|
|
100
112
|
],
|
|
101
113
|
}),
|
|
102
114
|
],
|
|
103
115
|
builderConfig: {
|
|
104
116
|
plugins: [pluginYaml()],
|
|
105
117
|
server: {
|
|
106
|
-
open
|
|
118
|
+
open,
|
|
107
119
|
},
|
|
108
120
|
tools: {
|
|
109
121
|
rspack: {
|
|
@@ -120,7 +132,7 @@ const getCommonConfig = ({ config, root, configFilePath, base, version, download
|
|
|
120
132
|
const findConfig = (basePath) => {
|
|
121
133
|
return DEFAULT_EXTENSIONS.map((ext) => basePath + ext).find(fs.existsSync);
|
|
122
134
|
};
|
|
123
|
-
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, ignore, force, } = {}) {
|
|
135
|
+
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, ignore, force, open, } = {}) {
|
|
124
136
|
let configFilePath;
|
|
125
137
|
if (configFile) {
|
|
126
138
|
configFilePath = path.resolve(configFile);
|
|
@@ -179,6 +191,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
179
191
|
download,
|
|
180
192
|
ignore,
|
|
181
193
|
force,
|
|
194
|
+
open,
|
|
182
195
|
});
|
|
183
196
|
base = commonConfig.base;
|
|
184
197
|
const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
2
|
import { fromHtml } from 'hast-util-from-html';
|
|
3
|
+
import { logger } from '@rspress/shared/logger';
|
|
3
4
|
// TODO: migrate to official @shikijs/rehype plugin after upgrading unified/remark/rehype packages
|
|
4
5
|
export const rehypePluginShiki = ({ highlighter, theme }) => (tree) => {
|
|
5
6
|
visit(tree, 'element', (node, index, parent) => {
|
|
@@ -16,13 +17,27 @@ export const rehypePluginShiki = ({ highlighter, theme }) => (tree) => {
|
|
|
16
17
|
if (!lang) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
let highlightedCode;
|
|
21
|
+
try {
|
|
22
|
+
highlightedCode = highlighter.codeToHtml(codeContent, {
|
|
23
|
+
lang,
|
|
24
|
+
theme,
|
|
25
|
+
meta: {
|
|
26
|
+
__raw: codeMeta,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
logger.error(`render with \`${lang}\` results error`, err);
|
|
32
|
+
logger.warn('fallback to `plaintext`');
|
|
33
|
+
highlightedCode = highlighter.codeToHtml(codeContent, {
|
|
34
|
+
lang: 'plaintext',
|
|
35
|
+
theme,
|
|
36
|
+
meta: {
|
|
37
|
+
__raw: codeMeta,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
26
41
|
const fragmentAst = fromHtml(highlightedCode, { fragment: true });
|
|
27
42
|
const preElement = fragmentAst.children[0];
|
|
28
43
|
const codeElement = preElement.children[0];
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { serve } from '@rspress/core';
|
|
2
|
-
import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.js';
|
|
2
|
+
import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, PluginShikiOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.js';
|
|
3
3
|
import type { DoomSite } from './shared/index.js';
|
|
4
4
|
export type BaseServeOptions = Parameters<typeof serve>[0];
|
|
5
5
|
export type ServeOptions = Omit<BaseServeOptions, 'config'>;
|
|
@@ -11,6 +11,7 @@ export interface GlobalCliOptions {
|
|
|
11
11
|
download?: boolean;
|
|
12
12
|
ignore?: boolean;
|
|
13
13
|
force?: boolean;
|
|
14
|
+
open?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export interface TranslateOptions {
|
|
16
17
|
systemPrompt?: string;
|
|
@@ -27,6 +28,7 @@ declare module '@rspress/shared' {
|
|
|
27
28
|
releaseNotes?: ReleaseNotesOptions;
|
|
28
29
|
internalRoutes?: string[];
|
|
29
30
|
translate?: TranslateOptions;
|
|
31
|
+
shiki?: PluginShikiOptions;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
export type ContentProcessor = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint": "run-p 'lint:*'",
|
|
37
37
|
"lint:es": "eslint .",
|
|
38
38
|
"lint:tsc": "tsc -b",
|
|
39
|
-
"prepare": "simple-git-hooks && patch-package",
|
|
39
|
+
"prepare": "simple-git-hooks && patch-package && yarn-berry-deduplicate",
|
|
40
40
|
"prepublishOnly": "yarn build",
|
|
41
41
|
"serve": "yarn doom serve",
|
|
42
42
|
"swc-node": "node --enable-source-maps --import @swc-node/register/esm-register",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
48
48
|
"@playwright/browser-chromium": "^1.51.0",
|
|
49
49
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
50
|
-
"@rspress/core": "1.43.
|
|
50
|
+
"@rspress/core": "1.43.7",
|
|
51
51
|
"@shikijs/transformers": "^3.2.1",
|
|
52
52
|
"chokidar": "^4.0.3",
|
|
53
53
|
"cli-progress": "^3.12.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@eslint/js": "^9.22.0",
|
|
83
83
|
"@swc-node/register": "^1.10.10",
|
|
84
|
-
"@swc/core": "1.11.
|
|
84
|
+
"@swc/core": "1.11.11",
|
|
85
85
|
"@types/cli-progress": "^3.11.6",
|
|
86
86
|
"@types/ejs": "^3.1.5",
|
|
87
87
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -98,7 +98,8 @@
|
|
|
98
98
|
"prettier-plugin-pkg": "^0.18.1",
|
|
99
99
|
"simple-git-hooks": "^2.11.1",
|
|
100
100
|
"typescript": "^5.8.2",
|
|
101
|
-
"typescript-eslint": "^8.26.1"
|
|
101
|
+
"typescript-eslint": "^8.26.1",
|
|
102
|
+
"yarn-berry-deduplicate": "^6.1.1"
|
|
102
103
|
},
|
|
103
104
|
"publishConfig": {
|
|
104
105
|
"access": "public"
|
package/styles/global.scss
CHANGED
|
@@ -90,6 +90,18 @@ td {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
[class^='aside-container']:has(.hidden) {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[class*=' sticky_'] + section .rspress-local-toc-container {
|
|
98
|
+
margin-top: var(--rp-nav-height);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.rspress-sidebar-menu-container:has(ul:empty) {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
@mixin print {
|
|
94
106
|
.rspress {
|
|
95
107
|
&-nav,
|