@alauda/doom 1.20.4 → 1.21.0
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/export.js +1 -1
- package/lib/cli/load-config.js +21 -10
- package/lib/runtime/hooks/useSiteOverrides.js +6 -6
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +8 -0
- package/lib/runtime/translation.js +6 -0
- package/lib/theme/AutoExpandable.js +23 -7
- package/lib/theme/Layout.js +1 -1
- package/package.json +12 -13
- package/styles/auto-expandable.module.scss +2 -0
- package/styles/global.scss +33 -21
package/lib/cli/export.js
CHANGED
|
@@ -123,7 +123,7 @@ export const exportCommand = new Command('export')
|
|
|
123
123
|
children = generateOutlinesFromSidebar(item.items);
|
|
124
124
|
}
|
|
125
125
|
if ('link' in item && item.link) {
|
|
126
|
-
const page = pageMap.get(`${item.link}.html`);
|
|
126
|
+
const page = pageMap.get(`${config.base}${removeLeadingSlash(item.link)}.html`);
|
|
127
127
|
if (page != null) {
|
|
128
128
|
result.push({
|
|
129
129
|
title: page.title || item.text,
|
package/lib/cli/load-config.js
CHANGED
|
@@ -216,7 +216,7 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
216
216
|
return mergeConfig(rspackConfig, {
|
|
217
217
|
ignoreWarnings: [
|
|
218
218
|
{
|
|
219
|
-
module: /\
|
|
219
|
+
module: /\b(flexsearch|vscode-languageserver-types)\b/,
|
|
220
220
|
},
|
|
221
221
|
],
|
|
222
222
|
resolve: {
|
|
@@ -323,18 +323,29 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
323
323
|
lang,
|
|
324
324
|
});
|
|
325
325
|
base = commonConfig.base;
|
|
326
|
+
lang = commonConfig.lang;
|
|
327
|
+
root = commonConfig.root;
|
|
326
328
|
const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
|
|
327
329
|
base,
|
|
328
|
-
lang
|
|
329
|
-
root
|
|
330
|
+
lang,
|
|
331
|
+
root,
|
|
330
332
|
});
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
if (export_) {
|
|
334
|
+
const hasLocales = !!commonConfig.themeConfig.locales?.length;
|
|
335
|
+
const apiEntries = await glob(`${hasLocales ? commonConfig.lang + '/' : ''}apis/{advanced_apis,crds,kubernetes_apis}/*/index.{md,mdx}`, { cwd: root });
|
|
336
|
+
const apiExports = apiEntries.map((entry) => {
|
|
337
|
+
const scope = entry.replace(/index\.mdx?$/, '');
|
|
338
|
+
return {
|
|
339
|
+
name: path.basename(path.dirname(entry)) + '_apis',
|
|
340
|
+
scope: hasLocales ? scope.replace(lang, '*') : scope,
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
mergedConfig.export = await Promise.all([...(config.export ?? []), ...apiExports].map(async (item) => ({
|
|
344
|
+
...item,
|
|
345
|
+
scope: Array.isArray(item.scope) ? item.scope : [item.scope],
|
|
346
|
+
flattenScope: (await glob(item.scope, { cwd: root })).filter(isDoc),
|
|
347
|
+
})));
|
|
348
|
+
}
|
|
338
349
|
if (base && prefix) {
|
|
339
350
|
mergedConfig.base = (mergedConfig.prefix = normalizeSlash(prefix)) + base;
|
|
340
351
|
}
|
|
@@ -52,13 +52,13 @@ const fetchSiteOverrides = async (version, acpSite) => {
|
|
|
52
52
|
}))
|
|
53
53
|
.catch(() => ({ terms: namedTerms }))
|
|
54
54
|
.then(({ terms, ...siteOverrides }) => {
|
|
55
|
-
|
|
55
|
+
const overrides = normalizeOverrides(siteOverrides);
|
|
56
56
|
const normalizedTerms = normalizeOverrides(terms);
|
|
57
|
-
return {
|
|
58
|
-
en: { ...
|
|
59
|
-
zh: { ...
|
|
60
|
-
ru: { ...
|
|
61
|
-
};
|
|
57
|
+
return (normalizedSiteOverrides = {
|
|
58
|
+
en: { ...overrides.en, terms: normalizedTerms.en },
|
|
59
|
+
zh: { ...overrides.zh, terms: normalizedTerms.zh },
|
|
60
|
+
ru: { ...overrides.ru, terms: normalizedTerms.ru },
|
|
61
|
+
});
|
|
62
62
|
}));
|
|
63
63
|
};
|
|
64
64
|
export const useSiteOverrides = () => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Language } from '../../shared/index.js';
|
|
2
2
|
export declare const useLang: () => Language;
|
|
3
|
-
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "password" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat") => string;
|
|
3
|
+
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "password" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat" | "show_more" | "show_less") => string;
|
|
@@ -53,6 +53,8 @@ declare const en: {
|
|
|
53
53
|
view_more_related_docs: string;
|
|
54
54
|
view_less_related_docs: string;
|
|
55
55
|
new_chat: string;
|
|
56
|
+
show_more: string;
|
|
57
|
+
show_less: string;
|
|
56
58
|
};
|
|
57
59
|
export type Translation = typeof en;
|
|
58
60
|
export declare const TRANSLATIONS: {
|
|
@@ -111,6 +113,8 @@ export declare const TRANSLATIONS: {
|
|
|
111
113
|
view_more_related_docs: string;
|
|
112
114
|
view_less_related_docs: string;
|
|
113
115
|
new_chat: string;
|
|
116
|
+
show_more: string;
|
|
117
|
+
show_less: string;
|
|
114
118
|
};
|
|
115
119
|
zh: {
|
|
116
120
|
collapse_all: string;
|
|
@@ -167,6 +171,8 @@ export declare const TRANSLATIONS: {
|
|
|
167
171
|
view_more_related_docs: string;
|
|
168
172
|
view_less_related_docs: string;
|
|
169
173
|
new_chat: string;
|
|
174
|
+
show_more: string;
|
|
175
|
+
show_less: string;
|
|
170
176
|
};
|
|
171
177
|
ru: {
|
|
172
178
|
collapse_all: string;
|
|
@@ -223,6 +229,8 @@ export declare const TRANSLATIONS: {
|
|
|
223
229
|
view_more_related_docs: string;
|
|
224
230
|
view_less_related_docs: string;
|
|
225
231
|
new_chat: string;
|
|
232
|
+
show_more: string;
|
|
233
|
+
show_less: string;
|
|
226
234
|
};
|
|
227
235
|
};
|
|
228
236
|
export {};
|
|
@@ -53,6 +53,8 @@ const en = {
|
|
|
53
53
|
view_more_related_docs: 'View more related docs',
|
|
54
54
|
view_less_related_docs: 'View less related docs',
|
|
55
55
|
new_chat: 'New Chat',
|
|
56
|
+
show_more: 'Show more',
|
|
57
|
+
show_less: 'Show less',
|
|
56
58
|
};
|
|
57
59
|
const zh = {
|
|
58
60
|
collapse_all: '全部收起',
|
|
@@ -109,6 +111,8 @@ const zh = {
|
|
|
109
111
|
view_more_related_docs: '查看更多相关文档',
|
|
110
112
|
view_less_related_docs: '查看更少相关文档',
|
|
111
113
|
new_chat: '新会话',
|
|
114
|
+
show_more: '显示更多',
|
|
115
|
+
show_less: '显示更少',
|
|
112
116
|
};
|
|
113
117
|
const ru = {
|
|
114
118
|
collapse_all: 'Свернуть всё',
|
|
@@ -165,5 +169,7 @@ const ru = {
|
|
|
165
169
|
view_more_related_docs: 'Посмотреть больше связанных документов',
|
|
166
170
|
view_less_related_docs: 'Посмотреть меньше связанных документов',
|
|
167
171
|
new_chat: 'Новый чат',
|
|
172
|
+
show_more: 'Показать больше',
|
|
173
|
+
show_less: 'Показать меньше',
|
|
168
174
|
};
|
|
169
175
|
export const TRANSLATIONS = { en, zh, ru };
|
|
@@ -2,29 +2,45 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { IconDown, SvgWrapper } from '@rspress/core/theme';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { useIsPrint } from '../runtime/index.js';
|
|
5
|
+
import { useIsPrint, useTranslation } from '../runtime/index.js';
|
|
6
6
|
import classes from '@alauda/doom/styles/auto-expandable.module.scss';
|
|
7
7
|
export const AutoExpandable = ({ threshold = 240, children, }) => {
|
|
8
|
+
const t = useTranslation();
|
|
8
9
|
const ref = useRef(null);
|
|
9
10
|
const isPrint = useIsPrint();
|
|
10
11
|
const [expandable, setExpandable] = useState(false);
|
|
11
12
|
const [expanded, setExpanded] = useState(false);
|
|
12
13
|
useEffect(() => {
|
|
13
|
-
|
|
14
|
+
const containerEl = ref.current;
|
|
15
|
+
if (!containerEl || isPrint) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let observer;
|
|
19
|
+
const calculate = () => {
|
|
20
|
+
if (containerEl.scrollHeight > threshold) {
|
|
21
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
22
|
+
setExpandable(true);
|
|
23
|
+
}
|
|
24
|
+
observer?.disconnect();
|
|
25
|
+
};
|
|
26
|
+
calculate();
|
|
27
|
+
const tabItem = containerEl.closest('.rp-tabs__content__item--hidden');
|
|
28
|
+
if (tabItem) {
|
|
29
|
+
observer = new MutationObserver(calculate);
|
|
30
|
+
observer.observe(tabItem, { attributeFilter: ['class'] });
|
|
31
|
+
return () => {
|
|
32
|
+
observer?.disconnect();
|
|
33
|
+
};
|
|
19
34
|
}
|
|
20
35
|
}, [threshold, isPrint]);
|
|
21
36
|
const onExpandChange = useCallback(() => {
|
|
22
37
|
setExpanded((expanded) => !expanded);
|
|
23
38
|
}, []);
|
|
24
|
-
return (_jsxs("div", { ref: ref, className: classes.container
|
|
39
|
+
return (_jsxs("div", { ref: ref, className: `${classes.container} auto-expandable`, children: [_jsx("div", { className: clsx({
|
|
40
|
+
expandable,
|
|
25
41
|
[classes.expandable]: expandable,
|
|
26
42
|
[classes.expanded]: expanded,
|
|
27
|
-
}), children: children }), expandable && (_jsx("div", { className: classes.actionContainer, children: _jsxs("button", { className: classes.action, type: "button", onClick: onExpandChange, "aria-expanded": expanded, children: [
|
|
43
|
+
}), children: children }), expandable && (_jsx("div", { className: classes.actionContainer, children: _jsxs("button", { className: classes.action, type: "button", onClick: onExpandChange, "aria-expanded": expanded, children: [t(`show_${expanded ? 'less' : 'more'}`), _jsx(SvgWrapper, { className: clsx(classes.arrow, {
|
|
28
44
|
[classes.expanded]: expanded,
|
|
29
45
|
}), icon: IconDown })] }) }))] }));
|
|
30
46
|
};
|
package/lib/theme/Layout.js
CHANGED
|
@@ -24,7 +24,7 @@ const getClosestSidebar_ = (sidebarItems, pathname, exportItem, matched, depth =
|
|
|
24
24
|
if (depth === 0) {
|
|
25
25
|
matched = undefined;
|
|
26
26
|
}
|
|
27
|
-
if (exportItem.flattenScope
|
|
27
|
+
if (exportItem.flattenScope?.includes(sidebar._fileKey)) {
|
|
28
28
|
matched = {
|
|
29
29
|
sidebar,
|
|
30
30
|
exportItem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"rspress-plugins"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@alauda/doom-export": "^0.4.
|
|
43
|
+
"@alauda/doom-export": "^0.4.1",
|
|
44
44
|
"@cspell/eslint-plugin": "^9.7.0",
|
|
45
45
|
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
46
46
|
"@inquirer/prompts": "^8.3.0",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"@rsbuild/plugin-sass": "^1.5.0",
|
|
50
50
|
"@rsbuild/plugin-svgr": "^1.3.0",
|
|
51
51
|
"@rsbuild/plugin-yaml": "^1.0.4",
|
|
52
|
-
"@rspress/core": "2.0.
|
|
53
|
-
"@rspress/plugin-algolia": "2.0.
|
|
54
|
-
"@rspress/plugin-sitemap": "2.0.
|
|
55
|
-
"@rspress/shared": "2.0.
|
|
56
|
-
"@shikijs/transformers": "^
|
|
52
|
+
"@rspress/core": "2.0.4",
|
|
53
|
+
"@rspress/plugin-algolia": "2.0.4",
|
|
54
|
+
"@rspress/plugin-sitemap": "2.0.4",
|
|
55
|
+
"@rspress/shared": "2.0.4",
|
|
56
|
+
"@shikijs/transformers": "^4.0.1",
|
|
57
57
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
58
58
|
"@types/react": "^19.2.14",
|
|
59
59
|
"ab64": "^0.1.6",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
62
|
"commander": "^14.0.3",
|
|
63
63
|
"ejs": "^4.0.1",
|
|
64
|
-
"es-toolkit": "^1.
|
|
64
|
+
"es-toolkit": "^1.45.0",
|
|
65
65
|
"eslint": "^9.39.3",
|
|
66
|
-
"eslint-plugin-mdx": "^3.
|
|
67
|
-
"globals": "^17.
|
|
66
|
+
"eslint-plugin-mdx": "^3.7.0",
|
|
67
|
+
"globals": "^17.4.0",
|
|
68
68
|
"html-tag-names": "^2.1.0",
|
|
69
69
|
"jsencrypt": "^3.5.4",
|
|
70
70
|
"masonry-layout": "^4.2.2",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"mdast-util-to-markdown": "^2.1.2",
|
|
75
75
|
"mdast-util-to-string": "^4.0.0",
|
|
76
76
|
"mermaid": "^11.12.3",
|
|
77
|
-
"openai": "^6.
|
|
77
|
+
"openai": "^6.25.0",
|
|
78
78
|
"openapi-types": "^12.1.3",
|
|
79
79
|
"p-ratelimit": "^1.0.1",
|
|
80
80
|
"picomatch": "^4.0.3",
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
"remark-mdx": "^3.1.1",
|
|
96
96
|
"remark-message-control": "^8.0.0",
|
|
97
97
|
"remark-stringify": "^11.0.0",
|
|
98
|
-
"
|
|
99
|
-
"simple-git": "^3.32.2",
|
|
98
|
+
"simple-git": "^3.32.3",
|
|
100
99
|
"string-width": "^8.2.0",
|
|
101
100
|
"swagger2openapi": "^7.0.8",
|
|
102
101
|
"tinyglobby": "^0.2.15",
|
package/styles/global.scss
CHANGED
|
@@ -94,24 +94,6 @@ td {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.rp-tabs {
|
|
98
|
-
.rp-codeblock {
|
|
99
|
-
// https://github.com/web-infra-dev/rspress/blob/bbe6476c8394f9c95a98fd791f0614481f89d878/packages/theme-default/src/styles/code.css#L6
|
|
100
|
-
--rp-code-block-bg: #{color.adjust($color: #f6f8fa, $lightness: -5%)};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
&__content {
|
|
104
|
-
&__item {
|
|
105
|
-
padding: 0 1rem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
> :first-child,
|
|
109
|
-
> :last-child {
|
|
110
|
-
margin: 1rem 0;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
97
|
.doom-auto-toc {
|
|
116
98
|
@media (min-width: 1280px) {
|
|
117
99
|
display: none;
|
|
@@ -132,12 +114,25 @@ td {
|
|
|
132
114
|
}
|
|
133
115
|
}
|
|
134
116
|
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
117
|
+
.auto-expandable:has(> div > .rp-codeblock) {
|
|
118
|
+
background-color: var(--rp-code-block-bg);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dark .rp-tabs .auto-expandable:has(> div > .rp-codeblock) {
|
|
122
|
+
// https://github.com/web-infra-dev/rspress/blob/66fe9f837f4cecab859b57f6f10efc6d4d413f1b/packages/core/src/theme/styles/vars/base-vars.css#L26
|
|
123
|
+
--rp-code-block-bg: #{color.adjust($color: #121212, $lightness: 5%)};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rp-tabs .auto-expandable:has(> div > .rp-codeblock) {
|
|
127
|
+
// https://github.com/web-infra-dev/rspress/blob/66fe9f837f4cecab859b57f6f10efc6d4d413f1b/packages/core/src/theme/styles/vars/base-vars.css#L3
|
|
128
|
+
--rp-code-block-bg: #{color.adjust($color: #fff, $lightness: -5%)};
|
|
138
129
|
}
|
|
139
130
|
|
|
140
131
|
.rp {
|
|
132
|
+
&-nav-menu .rp-hover-group__item--active a[target='_blank']:after {
|
|
133
|
+
display: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
141
136
|
&-sidebar-item {
|
|
142
137
|
word-break: break-word;
|
|
143
138
|
}
|
|
@@ -178,6 +173,23 @@ td {
|
|
|
178
173
|
content: counters(section, '.') '. ';
|
|
179
174
|
}
|
|
180
175
|
}
|
|
176
|
+
|
|
177
|
+
&-tabs {
|
|
178
|
+
&__content {
|
|
179
|
+
&__item {
|
|
180
|
+
padding: 0 1rem;
|
|
181
|
+
|
|
182
|
+
> :first-child,
|
|
183
|
+
> :last-child {
|
|
184
|
+
margin: 1rem 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&-table-scroll-container:has(> table) {
|
|
191
|
+
margin: 1rem 0;
|
|
192
|
+
}
|
|
181
193
|
}
|
|
182
194
|
|
|
183
195
|
@mixin print {
|