@alauda/doom 0.3.1 → 0.3.2
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
CHANGED
|
@@ -6,6 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { logger } from '@rsbuild/core';
|
|
7
7
|
import { build, dev, serve } from '@rspress/core';
|
|
8
8
|
import { watch } from 'chokidar';
|
|
9
|
+
// import type { EventName } from 'chokidar/handler.js'
|
|
9
10
|
import { program } from 'commander';
|
|
10
11
|
import { green } from 'yoctocolors';
|
|
11
12
|
import module from 'node:module';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SidebarDivider, type SidebarGroup, type SidebarItem, type SidebarSectionHeader } from '@rspress/shared';
|
|
2
2
|
export interface DoomSidebarItem extends SidebarItem {
|
|
3
3
|
weight?: number;
|
|
4
4
|
}
|
|
@@ -12,7 +12,7 @@ export declare function scanSideMeta(workDir: string, rootDir: string, docsDir:
|
|
|
12
12
|
others: DoomSidebar[];
|
|
13
13
|
}>;
|
|
14
14
|
export declare function walk(workDir: string, routePrefix: string | undefined, docsDir: string, extensions: string[]): Promise<{
|
|
15
|
-
nav:
|
|
15
|
+
nav: never[];
|
|
16
16
|
sidebar: {
|
|
17
17
|
[x: string]: DoomSidebar[];
|
|
18
18
|
};
|
|
@@ -163,28 +163,6 @@ export async function scanSideMeta(workDir, rootDir, docsDir, routePrefix, exten
|
|
|
163
163
|
// Start walking from the doc directory, scan the `_meta.json` file in each subdirectory
|
|
164
164
|
// and generate the nav and sidebar config
|
|
165
165
|
export async function walk(workDir, routePrefix = '/', docsDir, extensions) {
|
|
166
|
-
// find the `_meta.json` file
|
|
167
|
-
const rootMetaFile = path.resolve(workDir, '_meta.json');
|
|
168
|
-
let navConfig;
|
|
169
|
-
// Get the nav config from the `_meta.json` file
|
|
170
|
-
try {
|
|
171
|
-
navConfig = (await fs.readJSON(rootMetaFile, 'utf8'));
|
|
172
|
-
}
|
|
173
|
-
catch {
|
|
174
|
-
navConfig = [];
|
|
175
|
-
}
|
|
176
|
-
navConfig.forEach((navItem) => {
|
|
177
|
-
if ('items' in navItem) {
|
|
178
|
-
navItem.items.forEach((item) => {
|
|
179
|
-
if ('link' in item && !isExternalUrl(item.link)) {
|
|
180
|
-
item.link = withBase(item.link, routePrefix);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if ('link' in navItem && !isExternalUrl(navItem.link)) {
|
|
185
|
-
navItem.link = withBase(navItem.link, routePrefix);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
166
|
const { index, others } = await scanSideMeta(workDir, workDir, docsDir, routePrefix, extensions, ['assets', 'public', 'shared']);
|
|
189
167
|
const sidebars = index ? [index, ...others] : others;
|
|
190
168
|
for (const sidebarItem of sidebars) {
|
|
@@ -200,7 +178,7 @@ export async function walk(workDir, routePrefix = '/', docsDir, extensions) {
|
|
|
200
178
|
sidebarConfig[removeTrailingSlash(routePrefix)] = sidebars;
|
|
201
179
|
}
|
|
202
180
|
return {
|
|
203
|
-
nav:
|
|
181
|
+
nav: [],
|
|
204
182
|
sidebar: sidebarConfig,
|
|
205
183
|
};
|
|
206
184
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { dirname, join } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
1
|
import { createCssVariablesTheme, } from 'shiki';
|
|
2
|
+
import { getHighlighter } from './highlighter.js';
|
|
4
3
|
import { rehypePluginShiki } from './rehypePlugin.js';
|
|
5
4
|
import { SHIKI_TRANSFORMER_LINE_NUMBER, createTransformerLineNumber, } from './transformers/line-number.js';
|
|
6
|
-
import { getHighlighter } from './highlighter.js';
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = dirname(__filename);
|
|
9
5
|
export const SHIKI_DEFAULT_HIGHLIGHT_LANGUAGES = [
|
|
10
6
|
'js',
|
|
11
7
|
'ts',
|
|
@@ -55,7 +51,6 @@ export function shikiPlugin({ theme = 'css-variables', langs = [], transformers
|
|
|
55
51
|
]);
|
|
56
52
|
return config;
|
|
57
53
|
},
|
|
58
|
-
globalStyles: join(__dirname, './shiki.css'),
|
|
59
54
|
};
|
|
60
55
|
}
|
|
61
56
|
export * from './transformers/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fixture": "yarn doom fixture-docs",
|
|
32
32
|
"lint": "run-p 'lint:*'",
|
|
33
33
|
"lint:es": "eslint .",
|
|
34
|
-
"lint:tsc": "tsc -b
|
|
34
|
+
"lint:tsc": "tsc -b",
|
|
35
35
|
"prepare": "simple-git-hooks",
|
|
36
36
|
"prepublishOnly": "yarn build",
|
|
37
37
|
"swc-node": "node --enable-source-maps --import @swc-node/register/esm-register"
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
41
41
|
"@rspress/core": "^1.38.0",
|
|
42
42
|
"@rspress/plugin-preview": "^1.38.0",
|
|
43
|
-
"@shikijs/transformers": "^1.24.
|
|
44
|
-
"chokidar": "^4.0.
|
|
43
|
+
"@shikijs/transformers": "^1.24.3",
|
|
44
|
+
"chokidar": "^4.0.3",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
46
|
"commander": "^12.1.0",
|
|
47
47
|
"es-toolkit": "^1.30.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-markdown": "^8.0.7",
|
|
50
50
|
"rehype-raw": "^6.1.1",
|
|
51
51
|
"remark-gfm": "^3.0.1",
|
|
52
|
-
"shiki": "^1.24.
|
|
52
|
+
"shiki": "^1.24.3",
|
|
53
53
|
"swagger2openapi": "^7.0.8",
|
|
54
54
|
"tinyglobby": "^0.2.10",
|
|
55
55
|
"yaml": "^2.6.1",
|
|
@@ -61,17 +61,17 @@
|
|
|
61
61
|
"@swc/core": "1.10.1",
|
|
62
62
|
"@types/eslint__js": "^8.42.3",
|
|
63
63
|
"@types/fs-extra": "^11.0.4",
|
|
64
|
-
"@types/node": "
|
|
64
|
+
"@types/node": "^18.19.68",
|
|
65
65
|
"@types/swagger2openapi": "^7.0.4",
|
|
66
66
|
"eslint": "^9.17.0",
|
|
67
67
|
"lint-staged": "^15.2.11",
|
|
68
|
-
"npm-run-all2": "^7.0.
|
|
68
|
+
"npm-run-all2": "^7.0.2",
|
|
69
69
|
"openapi-types": "^12.1.3",
|
|
70
70
|
"prettier": "^3.4.2",
|
|
71
71
|
"prettier-plugin-pkg": "^0.18.1",
|
|
72
72
|
"simple-git-hooks": "^2.11.1",
|
|
73
73
|
"typescript": "^5.7.2",
|
|
74
|
-
"typescript-eslint": "^8.18.
|
|
74
|
+
"typescript-eslint": "^8.18.1"
|
|
75
75
|
},
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
package/styles/global.scss
CHANGED
package/styles/shiki.css
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom shiki code block theme
|
|
3
|
+
* reference: https://github.com/shikijs/shiki/blob/main/docs/themes.md
|
|
4
|
+
* -------------------------------------------------------------------------- */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--shiki-foreground: #414141;
|
|
8
|
+
--shiki-background: transparent;
|
|
9
|
+
--shiki-token-constant: #1976d2;
|
|
10
|
+
--shiki-token-string: #31a94d;
|
|
11
|
+
--shiki-token-comment: rgb(182, 180, 180);
|
|
12
|
+
--shiki-token-keyword: #cf2727;
|
|
13
|
+
--shiki-token-parameter: #f59403;
|
|
14
|
+
--shiki-token-function: #7041c8;
|
|
15
|
+
--shiki-token-string-expression: #218438;
|
|
16
|
+
--shiki-token-punctuation: #242323;
|
|
17
|
+
--shiki-token-link: #22863a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.dark {
|
|
21
|
+
--shiki-foreground: #cac7c7;
|
|
22
|
+
--shiki-token-constant: #6fb0fa;
|
|
23
|
+
--shiki-token-string: #f9a86e;
|
|
24
|
+
--shiki-token-comment: #6a727b;
|
|
25
|
+
--shiki-token-keyword: #f47481;
|
|
26
|
+
--shiki-token-parameter: #ff9800;
|
|
27
|
+
--shiki-token-function: #ae8eeb;
|
|
28
|
+
--shiki-token-string-expression: #4fb74d;
|
|
29
|
+
--shiki-token-punctuation: #bbbbbb;
|
|
30
|
+
--shiki-token-link: #f9a76d;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rspress-doc span.line {
|
|
34
|
+
padding: 0 1.25rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.diff,
|
|
38
|
+
.code-line-highlighted {
|
|
39
|
+
transition: background-color 0.5s;
|
|
40
|
+
padding: 0 20px;
|
|
41
|
+
width: 100%;
|
|
42
|
+
display: inline-block;
|
|
43
|
+
position: relative;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.diff.add::after {
|
|
47
|
+
content: '+';
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 10px;
|
|
50
|
+
color: #3dd68c;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.diff.remove::after {
|
|
54
|
+
content: '-';
|
|
55
|
+
position: absolute;
|
|
56
|
+
left: 10px;
|
|
57
|
+
color: #cb7676;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.has-diff div[class*='language-'] .diff.add {
|
|
61
|
+
background-color: rgba(16, 185, 129, 0.16);
|
|
62
|
+
border-left: 1px solid #10b981;
|
|
63
|
+
padding: 0 20px 0 19px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
div[class*='language-'] code .diff.remove {
|
|
67
|
+
background-color: rgba(244, 63, 94, 0.16);
|
|
68
|
+
border-left: 1px solid #f43f5e;
|
|
69
|
+
padding: 0 20px 0 19px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.has-highlight div[class*='language-'] .line.highlighted {
|
|
73
|
+
background-color: rgba(101, 117, 133, 0.16);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.has-highlight div[class*='language-'] .line.highlighted.error {
|
|
77
|
+
background-color: rgba(244, 63, 94, 0.16);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.has-highlight div[class*='language-'] .line.highlighted.warning {
|
|
81
|
+
background-color: rgba(234, 179, 8, 0.16);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.has-focused div[class*='language-'] .line:not(.focused) {
|
|
85
|
+
filter: blur(0.095rem);
|
|
86
|
+
opacity: 0.4;
|
|
87
|
+
transition: filter 0.35s, opacity 0.35s;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.has-focused:hover div[class*='language-'] .line:not(.focused) {
|
|
91
|
+
filter: blur(0);
|
|
92
|
+
opacity: 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.has-line-number code {
|
|
96
|
+
counter-reset: step;
|
|
97
|
+
counter-increment: step 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.has-line-number code .line-number::before {
|
|
101
|
+
content: counter(step);
|
|
102
|
+
counter-increment: step;
|
|
103
|
+
width: 15px;
|
|
104
|
+
margin-right: 15px;
|
|
105
|
+
display: inline-block;
|
|
106
|
+
text-align: right;
|
|
107
|
+
color: rgba(115, 138, 148, 0.4);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.line .highlighted-word {
|
|
111
|
+
background-color: var(--rp-c-text-code-bg);
|
|
112
|
+
border: 1px solid var(--rp-c-divider);
|
|
113
|
+
color: var(--rp-c-text-code);
|
|
114
|
+
padding: 1px 3px;
|
|
115
|
+
margin: -1px -3px;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
}
|