@alauda/doom 0.23.9 → 0.23.11
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/new.js +1 -1
- package/lib/cli/translate.js +1 -1
- package/lib/global/SiteOverrides/index.js +8 -1
- package/lib/global/VersionsNav/index.js +2 -1
- package/lib/runtime/components/ExternalSiteLink.js +1 -1
- package/lib/runtime/components/K8sCrd.js +5 -4
- package/lib/runtime/components/K8sPermissionTable.js +11 -11
- package/lib/runtime/components/Mermaid.js +1 -1
- package/lib/runtime/components/OpenAPIPath.js +4 -2
- package/lib/runtime/components/OpenAPIRef.js +7 -7
- package/lib/runtime/components/Overview.js +31 -31
- package/lib/runtime/components/Tabs.js +5 -1
- package/lib/runtime/components/TermsTable.js +3 -1
- package/lib/runtime/components/_ExternalSiteBase.js +2 -2
- package/lib/runtime/components/_HeadingTitle.js +7 -8
- package/lib/runtime/hooks/useIsPrint.js +1 -1
- package/lib/runtime/hooks/useSiteOverrides.js +1 -1
- package/package.json +10 -9
package/lib/cli/new.js
CHANGED
|
@@ -107,7 +107,7 @@ export const newCommand = new Command('new')
|
|
|
107
107
|
const source = path.resolve(base, render(layout.source, { parameters }));
|
|
108
108
|
const target = path.resolve(render(layout.target, { parameters }));
|
|
109
109
|
const when = layout.when && render(layout.when, { parameters });
|
|
110
|
-
if (JS_STR_FALSY_VALUES.has(when)) {
|
|
110
|
+
if (when != null && JS_STR_FALSY_VALUES.has(when)) {
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
switch (layout.type) {
|
package/lib/cli/translate.js
CHANGED
|
@@ -90,7 +90,7 @@ export const translate = async ({ source, sourceContent, target, targetContent =
|
|
|
90
90
|
terms = await resolveTerms();
|
|
91
91
|
}
|
|
92
92
|
const finalSystemPrompt = await render(systemPrompt?.trim() || DEFAULT_SYSTEM_PROMPT, { sourceLang, targetLang, userPrompt, additionalPrompts, terms }, { async: true });
|
|
93
|
-
const { choices } = await openai.
|
|
93
|
+
const { choices } = await openai.chat.completions.parse({
|
|
94
94
|
messages: [
|
|
95
95
|
{
|
|
96
96
|
role: 'system',
|
|
@@ -52,7 +52,14 @@ export const SiteOverrides = () => {
|
|
|
52
52
|
requestAnimationFrame(() => {
|
|
53
53
|
document.title = newTitle;
|
|
54
54
|
});
|
|
55
|
-
}, [
|
|
55
|
+
}, [
|
|
56
|
+
articleTitle,
|
|
57
|
+
frontmatter.title,
|
|
58
|
+
frontmatter.titleSuffix,
|
|
59
|
+
pageType,
|
|
60
|
+
siteData,
|
|
61
|
+
title,
|
|
62
|
+
]);
|
|
56
63
|
useEffect(() => {
|
|
57
64
|
if (!logoText) {
|
|
58
65
|
return;
|
|
@@ -71,7 +71,7 @@ const VersionsNav_ = () => {
|
|
|
71
71
|
setNavMenu(getNavMenu);
|
|
72
72
|
};
|
|
73
73
|
void fetchVersions().catch(noop);
|
|
74
|
-
}, []);
|
|
74
|
+
}, [version, versionsBase]);
|
|
75
75
|
// hack way to detect nav menu recreation on theme change
|
|
76
76
|
useEffect(() => {
|
|
77
77
|
if (!navMenu) {
|
|
@@ -84,6 +84,7 @@ const VersionsNav_ = () => {
|
|
|
84
84
|
});
|
|
85
85
|
const newNavMenu = getNavMenu();
|
|
86
86
|
if (newNavMenu !== navMenu) {
|
|
87
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
87
88
|
setNavMenu(newNavMenu);
|
|
88
89
|
}
|
|
89
90
|
else if (navMenu.parentNode) {
|
|
@@ -11,7 +11,7 @@ import { useIsPrint } from '../hooks/index.js';
|
|
|
11
11
|
import { Directive } from './Directive.js';
|
|
12
12
|
const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
13
13
|
const isPrint = useIsPrint();
|
|
14
|
-
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), []);
|
|
14
|
+
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), [name]);
|
|
15
15
|
const lang = useLang();
|
|
16
16
|
if (!site) {
|
|
17
17
|
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
@@ -14,6 +14,7 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, })
|
|
|
14
14
|
setOpen(open);
|
|
15
15
|
}, []);
|
|
16
16
|
useEffect(() => {
|
|
17
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
17
18
|
setOpen(expandAll);
|
|
18
19
|
}, [expandAll]);
|
|
19
20
|
const [props, required, type, schema] = useMemo(() => {
|
|
@@ -37,7 +38,7 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, })
|
|
|
37
38
|
}
|
|
38
39
|
return [props, required, type, schema];
|
|
39
40
|
}, [name, parent, property]);
|
|
40
|
-
return (_jsx(_Fragment, { children: _jsxs(Directive, { type: "details", title: _jsxs(_Fragment, { children: [name, type && _jsx("code", { children: type }), required && _jsx(Badge, { children: "required" })] }), open: open, onToggle: onToggle, children: [_jsx(Markdown, { children: schema.description }), props &&
|
|
41
|
+
return (_jsx(_Fragment, { children: _jsxs(Directive, { type: "details", title: _jsxs(_Fragment, { children: [name, type && (_jsxs(_Fragment, { children: [' ', _jsx("code", { children: type })] })), required && (_jsxs(_Fragment, { children: [' ', _jsx(Badge, { children: "required" })] }))] }), open: open, onToggle: onToggle, children: [_jsx(Markdown, { children: schema.description }), props &&
|
|
41
42
|
Object.entries(props).map(([name, subSchema]) => (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name)))] }) }));
|
|
42
43
|
};
|
|
43
44
|
const SKIPPED_PROPERTIES = ['apiVersion', 'kind', 'metadata'];
|
|
@@ -49,7 +50,7 @@ export const K8sCrdSchema = ({ schema, version, }) => {
|
|
|
49
50
|
const toggleExpandAll = useCallback(() => {
|
|
50
51
|
setExpandAll((all) => !all);
|
|
51
52
|
}, []);
|
|
52
|
-
return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx("code", { children: version }), _jsx(Badge, { children: "version" })] }), !isPrint && properties != null && (_jsx(Button, { className: "ml-auto doom-btn", type: "button", text: _jsxs("span", { onClick: toggleExpandAll, children: [expandAll ? '-' : '+', ' ', t(expandAll ? 'collapse_all' : 'expand_all')] }), size: "medium", theme: "alt" }))] }), properties == null ? (_jsx(Directive, { type: "warning", children: t('crd_no_schema') })) : (_jsx("div", { className: "doom-collapse-group", children: Object.entries(properties).map(([name, subSchema]) => SKIPPED_PROPERTIES.includes(name) || (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name))) }))] }));
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx("code", { children: version }), " ", _jsx(Badge, { children: "version" })] }), !isPrint && properties != null && (_jsx(Button, { className: "ml-auto doom-btn", type: "button", text: _jsxs("span", { onClick: toggleExpandAll, children: [expandAll ? '-' : '+', ' ', t(expandAll ? 'collapse_all' : 'expand_all')] }), size: "medium", theme: "alt" }))] }), properties == null ? (_jsx(Directive, { type: "warning", children: t('crd_no_schema') })) : (_jsx("div", { className: "doom-collapse-group", children: Object.entries(properties).map(([name, subSchema]) => SKIPPED_PROPERTIES.includes(name) || (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name))) }))] }));
|
|
53
54
|
};
|
|
54
55
|
export const K8sCrd = ({ name, crdPath }) => {
|
|
55
56
|
const [X] = useState(getCustomMDXComponent);
|
|
@@ -58,11 +59,11 @@ export const K8sCrd = ({ name, crdPath }) => {
|
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
61
|
return crd.metadata.name === name;
|
|
61
|
-
}) || [], []);
|
|
62
|
+
}) || [], [crdPath, name]);
|
|
62
63
|
if (!crd) {
|
|
63
64
|
console.error(`No CustomResourceDefinition found for ${name}`);
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
|
-
return (_jsxs(_Fragment, { children: [_jsxs(X.p, { children: [_jsx("code", { children: crd.spec.group }), _jsx(Badge, { children: "group" })] }), crd.spec.versions.map((version) => (_jsx(K8sCrdSchema, { schema: version.schema.openAPIV3Schema, version: version.name }, version.name)))] }));
|
|
67
|
+
return (_jsxs(_Fragment, { children: [_jsxs(X.p, { children: [_jsx("code", { children: crd.spec.group }), " ", _jsx(Badge, { children: "group" })] }), crd.spec.versions.map((version) => (_jsx(K8sCrdSchema, { schema: version.schema.openAPIV3Schema, version: version.name }, version.name)))] }));
|
|
67
68
|
};
|
|
68
69
|
export default K8sCrd;
|
|
@@ -48,19 +48,19 @@ const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
|
|
|
48
48
|
return (_jsx(X.td, { style: TEXT_CENTER_STYLE, children: hasPermission ? '✓' : '✕' }, name));
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
|
+
const allFunctionResources = Object.values(functionResourcesMap).reduce((acc, curr) => Object.assign(acc, ...curr.map((fr) => ({ [fr.metadata.name]: fr }))), {});
|
|
51
52
|
export const K8sPermissionTable = ({ functions }) => {
|
|
52
53
|
const [X] = useState(getCustomMDXComponent);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [...functions]);
|
|
54
|
+
const functionResources = useMemo(() => functions.flatMap((name) => {
|
|
55
|
+
const matched = allFunctionResources[name];
|
|
56
|
+
if (!matched) {
|
|
57
|
+
console.error(`FunctionResource \`${name}\` not found!\n`);
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return matched;
|
|
61
|
+
}),
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
functions);
|
|
64
64
|
const roleTemplates = useMemo(() => sortBy(Object.values(roleTemplatesMap).flat(), [
|
|
65
65
|
(it) => it.metadata.annotations['auth.cpaas.io/role.id'],
|
|
66
66
|
]), []);
|
|
@@ -17,7 +17,7 @@ export const Mermaid = ({ className, children }) => {
|
|
|
17
17
|
bindFunctions?.(container);
|
|
18
18
|
};
|
|
19
19
|
void render();
|
|
20
|
-
}, [children, isDark]);
|
|
20
|
+
}, [children, id, isDark]);
|
|
21
21
|
return (_jsx("div", { ref: containerRef, id: id, className: clsx('doom-mermaid', className) }));
|
|
22
22
|
};
|
|
23
23
|
export default Mermaid;
|
|
@@ -26,7 +26,9 @@ export const OpenAPIParameters = ({ parameters, openapi, }) => {
|
|
|
26
26
|
else if (type) {
|
|
27
27
|
typeNode = _jsx(RefLink, { "$ref": type.$ref });
|
|
28
28
|
}
|
|
29
|
-
return (
|
|
29
|
+
return (
|
|
30
|
+
// eslint-disable-next-line @eslint-react/no-array-index-key
|
|
31
|
+
_jsxs(X.li, { children: [_jsx("code", { children: paramObj.name }), " (", _jsxs("em", { children: ["in ", paramObj.in] }), "): ", typeNode, paramObj.required && (_jsxs(_Fragment, { children: [' ', _jsx(Badge, { children: "required" })] })), _jsxs(_Fragment, { children: [' ', _jsx(Markdown, { children: paramObj.description })] })] }, index));
|
|
30
32
|
}) }));
|
|
31
33
|
};
|
|
32
34
|
export const OpenAPIResponses = ({ responses, openapi, }) => {
|
|
@@ -111,7 +113,7 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
return [];
|
|
114
|
-
}, []);
|
|
116
|
+
}, [openapiPath_, page.routePath, path]);
|
|
115
117
|
if (!pathItem || !openapi) {
|
|
116
118
|
console.error(`No OpenAPI path definition found for ${path}`);
|
|
117
119
|
return null;
|
|
@@ -44,7 +44,7 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
|
44
44
|
};
|
|
45
45
|
export const OpenAPIProperties = ({ properties, openapi, }) => {
|
|
46
46
|
const [X] = useState(getCustomMDXComponent);
|
|
47
|
-
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property]
|
|
47
|
+
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property]) => (_jsx(X.li, { children: _jsx(OpenAPIProperty, { name: name, property: property, openapi: openapi }) }, name))) }));
|
|
48
48
|
};
|
|
49
49
|
const getRefsForSchema = (openapi, schema, knownRefs) => {
|
|
50
50
|
const refSchema = openapi.components?.schemas[schema];
|
|
@@ -86,16 +86,16 @@ export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, uid, collectRefs
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return [];
|
|
89
|
-
}, []);
|
|
90
|
-
if (!schemaItem || !openapi) {
|
|
91
|
-
console.error(`No OpenAPI schema definition found for ${schema}\n`);
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
89
|
+
}, [openapiPath_, schema]);
|
|
94
90
|
const refs = useMemo(() => {
|
|
95
|
-
if (collectRefs) {
|
|
91
|
+
if (collectRefs && openapi) {
|
|
96
92
|
return getRefsForSchema(openapi, schema, omitRoutePathRefs(page.routePath));
|
|
97
93
|
}
|
|
98
94
|
}, [collectRefs, openapi, page.routePath, schema]);
|
|
95
|
+
if (!schemaItem || !openapi) {
|
|
96
|
+
console.error(`No OpenAPI schema definition found for ${schema}\n`);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
99
|
return (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { uid: uid, slug: schema, level: 2, children: modelName(schema) }), _jsx(Markdown, { children: schemaItem.description }), schemaItem.properties && (_jsx(OpenAPIProperties, { properties: schemaItem.properties, openapi: openapi })), refs?.map((schema) => (_jsx(OpenAPIRef, { schema: schema, openapiPath: openapiPath, uid: uid, collectRefs: false }, schema)))] }));
|
|
100
100
|
};
|
|
101
101
|
export default OpenAPIRef;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Link, renderInlineMarkdown, useSidebarData } from '@rspress/core/theme';
|
|
3
3
|
import { isEqualPath, normalizeHrefInRuntime as normalizeHref, usePageData, withBase, } from '@rspress/runtime';
|
|
4
|
-
import { Fragment, useMemo } from 'react';
|
|
4
|
+
import { Fragment, useCallback, useMemo } from 'react';
|
|
5
5
|
import classes from '../../../styles/overview.module.scss';
|
|
6
6
|
import { findItemByRoutePath } from './_utils.js';
|
|
7
|
+
const getChildLink = (traverseItem) => {
|
|
8
|
+
if ('link' in traverseItem && traverseItem.link) {
|
|
9
|
+
return traverseItem.link;
|
|
10
|
+
}
|
|
11
|
+
if ('items' in traverseItem && traverseItem.items.length) {
|
|
12
|
+
return getChildLink(traverseItem.items[0]);
|
|
13
|
+
}
|
|
14
|
+
return '';
|
|
15
|
+
};
|
|
7
16
|
// The sidebar data include two types: sidebar item and sidebar group.
|
|
8
17
|
// In overpage page, we select all the related sidebar groups and show the groups in the page.
|
|
9
18
|
// In the meantime, some sidebar items also should be shown in the page, we collect them in the group named 'Others' and show them in the page.
|
|
10
19
|
export function Overview(props) {
|
|
11
20
|
const { siteData, page: { routePath, frontmatter, title }, } = usePageData();
|
|
12
21
|
const { content, groups: customGroups, defaultGroupTitle = 'Others' } = props;
|
|
13
|
-
const subFilter = (link) =>
|
|
22
|
+
const subFilter = useCallback((link) =>
|
|
14
23
|
// sidebar items link without base path
|
|
15
24
|
// pages route path with base path
|
|
16
25
|
withBase(link).startsWith(routePath.replace(/overview$/, '')) &&
|
|
17
|
-
!isEqualPath(withBase(link), routePath);
|
|
18
|
-
const getChildLink = (traverseItem) => {
|
|
19
|
-
if ('link' in traverseItem && traverseItem.link) {
|
|
20
|
-
return traverseItem.link;
|
|
21
|
-
}
|
|
22
|
-
if ('items' in traverseItem && traverseItem.items.length) {
|
|
23
|
-
return getChildLink(traverseItem.items[0]);
|
|
24
|
-
}
|
|
25
|
-
return '';
|
|
26
|
-
};
|
|
26
|
+
!isEqualPath(withBase(link), routePath), [routePath]);
|
|
27
27
|
const { pages } = siteData;
|
|
28
|
-
const overviewModules = pages.filter((page) => subFilter(page.routePath));
|
|
28
|
+
const overviewModules = useMemo(() => pages.filter((page) => subFilter(page.routePath)), [pages, subFilter]);
|
|
29
29
|
let overviewSidebarGroups = useSidebarData();
|
|
30
30
|
if (overviewSidebarGroups[0] &&
|
|
31
31
|
'link' in overviewSidebarGroups[0] &&
|
|
32
32
|
overviewSidebarGroups[0]?.link !== routePath) {
|
|
33
33
|
overviewSidebarGroups = findItemByRoutePath(overviewSidebarGroups, routePath);
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const normalizeSidebarItem = useCallback((item, sidebarGroup, frontmatter) => {
|
|
36
36
|
if ('dividerType' in item) {
|
|
37
37
|
return item;
|
|
38
38
|
}
|
|
@@ -55,9 +55,9 @@ export function Overview(props) {
|
|
|
55
55
|
link,
|
|
56
56
|
headers: pageModule?.toc.filter((header) => overviewHeaders.some((depth) => header.depth === depth)) || [],
|
|
57
57
|
};
|
|
58
|
-
}
|
|
58
|
+
}, [overviewModules, props.overviewHeaders, routePath]);
|
|
59
59
|
const isSingleFile = (item) => !('items' in item) && 'link' in item;
|
|
60
|
-
const getGroup = (sidebarGroups) => {
|
|
60
|
+
const getGroup = useCallback((sidebarGroups) => {
|
|
61
61
|
const group = sidebarGroups
|
|
62
62
|
.filter((sidebarGroup) => {
|
|
63
63
|
if ('items' in sidebarGroup) {
|
|
@@ -94,24 +94,24 @@ export function Overview(props) {
|
|
|
94
94
|
};
|
|
95
95
|
});
|
|
96
96
|
return group;
|
|
97
|
-
};
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
}, [frontmatter, normalizeSidebarItem, subFilter]);
|
|
98
|
+
const defaultGroups = useMemo(() => {
|
|
99
|
+
const group = getGroup(overviewSidebarGroups);
|
|
100
|
+
if (group.length) {
|
|
101
|
+
return group;
|
|
102
|
+
}
|
|
103
|
+
for (const sidebarGroup of overviewSidebarGroups) {
|
|
104
|
+
if (!('items' in sidebarGroup)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const group = getGroup(sidebarGroup.items);
|
|
101
108
|
if (group.length) {
|
|
102
109
|
return group;
|
|
103
110
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const group = getGroup(sidebarGroup.items);
|
|
109
|
-
if (group.length) {
|
|
110
|
-
return group;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return [];
|
|
114
|
-
}, [overviewSidebarGroups, routePath, frontmatter]);
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
}, [getGroup, overviewSidebarGroups]);
|
|
114
|
+
const groups = customGroups ?? defaultGroups;
|
|
115
115
|
return (_jsxs("div", { className: "overview-index doom-overview-index mx-auto", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(!title || [title, defaultGroupTitle].includes(group.name)) &&
|
|
116
116
|
groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx("h2", { children: renderInlineMarkdown(group.name) })), _jsx("div", { className: classes.overviewGroups, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup, children: [_jsx("h3", { style: { marginBottom: 8 }, children: _jsx(Link, { href: normalizeHref(item.link), children: renderInlineMarkdown(item.text) }) }), _jsx("div", { className: classes.overviewDescription, children: item.description }), _jsx("ul", { className: "list-none", children: item.headers?.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]} first:mt-2`, children: _jsx(Link, { href: `${normalizeHref(item.link)}#${header.id}`, children: renderInlineMarkdown(header.text) }) }, header.id))) })] }, item.link))) })] }, group.name)))] }));
|
|
117
117
|
}
|
|
@@ -4,6 +4,10 @@ import { Children, forwardRef, } from 'react';
|
|
|
4
4
|
import { useIsPrint } from '../hooks/index.js';
|
|
5
5
|
export const Tabs = forwardRef(({ children, ...props }, ref) => {
|
|
6
6
|
const isPrint = useIsPrint();
|
|
7
|
-
return (_jsx("div", { className: "doom-tabs", ref: ref, children: isPrint ? (
|
|
7
|
+
return (_jsx("div", { className: "doom-tabs", ref: ref, children: isPrint ? (
|
|
8
|
+
// eslint-disable-next-line @eslint-react/no-children-map
|
|
9
|
+
Children.map(children, (child, index) => (
|
|
10
|
+
// eslint-disable-next-line @eslint-react/no-array-index-key
|
|
11
|
+
_jsx(Tabs_, { ...props, children: child }, index)))) : (_jsx(Tabs_, { ...props, children: children })) }));
|
|
8
12
|
});
|
|
9
13
|
export default Tabs;
|
|
@@ -8,7 +8,9 @@ export const TermsTable = ({ terms }) => {
|
|
|
8
8
|
const t = useTranslation();
|
|
9
9
|
const normalized = terms ?? namedTermItems;
|
|
10
10
|
const withName = normalized.some(({ name }) => name);
|
|
11
|
-
const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
|
|
11
|
+
const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
|
|
12
|
+
// eslint-disable-next-line @eslint-react/no-array-index-key
|
|
13
|
+
_jsx(X.li, { children: item }, index))) })) : ('-');
|
|
12
14
|
return (_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs(X.tr, { children: [withName && _jsx(X.th, { children: t('name') }), _jsx(X.th, { children: t('chinese') }), _jsx(X.th, { children: t('chinese_bad_cases') }), _jsx(X.th, { children: t('english') }), _jsx(X.th, { children: t('english_bad_cases') }), _jsx(X.th, { children: t('description') })] }) }), _jsx("tbody", { children: normalized.map((term, index) => (_jsxs(X.tr, { children: [withName && _jsx(X.td, { children: term.name || '-' }), _jsx(X.td, { children: term.zh || term.en }), _jsx(X.td, { children: renderBadCases(term.badCases?.zh) }), _jsx(X.td, { children: term.en }), _jsx(X.td, { children: renderBadCases(term.badCases?.en) }), _jsx(X.td, { children: term.description || '-' })] }, term.name || index))) })] }));
|
|
13
15
|
};
|
|
14
16
|
export default TermsTable;
|
|
@@ -30,9 +30,9 @@ const ApisOverviewNotes = {
|
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
export const ExternalSiteBase = ({ name, template }) => {
|
|
33
|
-
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), []);
|
|
33
|
+
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), [name]);
|
|
34
34
|
const lang = useLang();
|
|
35
|
-
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.en || name.toUpperCase(), []);
|
|
35
|
+
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.en || name.toUpperCase(), [lang, name, site?.displayName]);
|
|
36
36
|
if (!site) {
|
|
37
37
|
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
38
38
|
}
|
|
@@ -9,14 +9,13 @@ export const HeadingTitle = ({ slug, slugger, uid, level, children, }) => {
|
|
|
9
9
|
return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
|
|
10
10
|
}, [X]);
|
|
11
11
|
const HeadingComponent = HeadingComponents[level];
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
12
|
+
const slugFromChildren = useMemo(() =>
|
|
13
|
+
// eslint-disable-next-line @eslint-react/no-children-to-array
|
|
14
|
+
Children.toArray(children)
|
|
15
|
+
.filter((it) => typeof it === 'string')
|
|
16
|
+
.join(''), [children]);
|
|
17
|
+
const id = useMemo(() => [uid, slug || slugger?.slug(slugFromChildren)]
|
|
19
18
|
.filter(Boolean)
|
|
20
|
-
.join('-') || undefined, [slug,
|
|
19
|
+
.join('-') || undefined, [uid, slug, slugger, slugFromChildren]);
|
|
21
20
|
return (_jsxs(HeadingComponent, { id: id, children: [children, _jsx(X.a, { className: "header-anchor", href: `#${id}`, "aria-hidden": true, children: "#" })] }));
|
|
22
21
|
};
|
|
@@ -22,7 +22,7 @@ export function useIsPrintMedia() {
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
printMediaQuery?.addEventListener('change', onChange);
|
|
24
24
|
return () => printMediaQuery?.removeEventListener('change', onChange);
|
|
25
|
-
}, [printMediaQuery]);
|
|
25
|
+
}, [onChange, printMediaQuery]);
|
|
26
26
|
return isPrint;
|
|
27
27
|
}
|
|
28
28
|
export function useIsPrint() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
@@ -33,27 +33,27 @@
|
|
|
33
33
|
"rspress-plugins"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@cspell/eslint-plugin": "^
|
|
37
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
36
|
+
"@cspell/eslint-plugin": "^8.19.4",
|
|
37
|
+
"@eslint-react/eslint-plugin": "^1.51.0",
|
|
38
38
|
"@inquirer/prompts": "^7.5.3",
|
|
39
39
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
40
40
|
"@playwright/browser-chromium": "^1.52.0",
|
|
41
41
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
42
42
|
"@rspress/core": "1.44.0",
|
|
43
|
-
"@shikijs/transformers": "^3.
|
|
43
|
+
"@shikijs/transformers": "^3.5.0",
|
|
44
44
|
"chokidar": "^4.0.3",
|
|
45
45
|
"cli-progress": "^3.12.0",
|
|
46
46
|
"clsx": "^2.1.1",
|
|
47
47
|
"commander": "^13.1.0",
|
|
48
48
|
"ejs": "^3.1.10",
|
|
49
|
-
"es-toolkit": "^1.
|
|
50
|
-
"eslint": "^9.
|
|
49
|
+
"es-toolkit": "^1.39.0",
|
|
50
|
+
"eslint": "^9.28.0",
|
|
51
51
|
"eslint-plugin-mdx": "^3.4.2",
|
|
52
52
|
"html-tag-names": "^2.1.0",
|
|
53
53
|
"mdast-util-mdx": "^2.0.1",
|
|
54
54
|
"mdast-util-mdx-jsx": "^2.1.4",
|
|
55
55
|
"mermaid": "^11.6.0",
|
|
56
|
-
"openai": "^5.
|
|
56
|
+
"openai": "^5.1.1",
|
|
57
57
|
"openapi-types": "^12.1.3",
|
|
58
58
|
"p-ratelimit": "^1.0.1",
|
|
59
59
|
"pdf-lib": "^1.17.1",
|
|
@@ -67,12 +67,13 @@
|
|
|
67
67
|
"remark-gfm": "^3.0.1",
|
|
68
68
|
"remark-mdx": "^2.3.0",
|
|
69
69
|
"remark-stringify": "^10.0.3",
|
|
70
|
-
"shiki": "^3.
|
|
70
|
+
"shiki": "^3.6.0",
|
|
71
71
|
"simple-git": "^3.27.0",
|
|
72
72
|
"swagger2openapi": "^7.0.8",
|
|
73
73
|
"tinyglobby": "^0.2.14",
|
|
74
74
|
"type-fest": "^4.41.0",
|
|
75
|
-
"typescript
|
|
75
|
+
"typescript": "^5.8.3",
|
|
76
|
+
"typescript-eslint": "^8.33.1",
|
|
76
77
|
"x-fetch": "^0.2.6",
|
|
77
78
|
"yaml": "^2.8.0",
|
|
78
79
|
"yoctocolors": "^2.1.1"
|