@alauda/doom 1.0.0-next.7 → 1.0.0-next.9
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/global/SiteOverrides/index.js +8 -1
- package/lib/global/VersionsNav/index.js +2 -1
- package/lib/plugins/replace/remark-replace.js +1 -1
- package/lib/plugins/replace/resolve-release.d.ts +1 -1
- package/lib/plugins/replace/resolve-release.js +14 -7
- 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.d.ts +3 -2
- package/lib/runtime/components/Tabs.js +8 -4
- package/lib/runtime/components/TermsTable.js +3 -1
- package/lib/runtime/components/_ExternalSiteBase.js +2 -2
- package/lib/runtime/components/_HeadingTitle.js +5 -3
- package/lib/runtime/hooks/useIsPrint.js +1 -1
- package/lib/runtime/hooks/useSiteOverrides.js +1 -1
- package/package.json +4 -4
|
@@ -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) {
|
|
@@ -159,7 +159,7 @@ export const remarkReplace = function ({ lang, localBasePath, root, items, force
|
|
|
159
159
|
continue;
|
|
160
160
|
}
|
|
161
161
|
if ((matched = node.value.match(isMdx ? MDX_RELEASE_PATTERN : MD_RELEASE_COMMENT_PATTERN))) {
|
|
162
|
-
const releaseContent = await resolveRelease(releaseNotes?.queryTemplates ?? {}, matched[1].trim(), currLang);
|
|
162
|
+
const releaseContent = await resolveRelease(releaseNotes?.queryTemplates ?? {}, matched[1].trim(), currLang, isMdx);
|
|
163
163
|
newAstChildren.push(releaseContent ?? node);
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { RootContent } from 'mdast';
|
|
2
|
-
export declare const resolveRelease: (releaseTemplates: Record<string, string>, releaseQuery: string, lang: string) => Promise<RootContent | RootContent[] | undefined>;
|
|
2
|
+
export declare const resolveRelease: (releaseTemplates: Record<string, string>, releaseQuery: string, lang: string, isMdx: boolean) => Promise<RootContent | RootContent[] | undefined>;
|
|
@@ -8,7 +8,7 @@ const FIELD_MAPPER = {
|
|
|
8
8
|
zh: 'customfield_13800',
|
|
9
9
|
en: 'customfield_13801',
|
|
10
10
|
};
|
|
11
|
-
const issuesToListItems = (issues, lang) => issues
|
|
11
|
+
const issuesToListItems = (issues, lang, isMdx) => issues
|
|
12
12
|
.map((issue) => {
|
|
13
13
|
const description = ((FIELD_MAPPER[lang] && issue.fields[FIELD_MAPPER[lang]]) ||
|
|
14
14
|
issue.fields[FIELD_MAPPER.en])?.trim();
|
|
@@ -25,9 +25,16 @@ const issuesToListItems = (issues, lang) => issues
|
|
|
25
25
|
.map((line) => ({ type: 'text', value: line }))
|
|
26
26
|
.reduce((acc, curr, index) => {
|
|
27
27
|
if (index === 0) {
|
|
28
|
-
|
|
28
|
+
acc.push(curr);
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
else {
|
|
31
|
+
acc.push(
|
|
32
|
+
// @ts-expect-error -- seems like a typing issue in mdast or TypeScript
|
|
33
|
+
isMdx
|
|
34
|
+
? { type: 'mdxJsxFlowElement', name: 'br' }
|
|
35
|
+
: { type: 'html', value: '<br>' }, curr);
|
|
36
|
+
}
|
|
37
|
+
return acc;
|
|
31
38
|
}, []),
|
|
32
39
|
},
|
|
33
40
|
],
|
|
@@ -40,7 +47,7 @@ const NO_ISSUE_MAPPER = {
|
|
|
40
47
|
zh: '此次发版无相关问题。',
|
|
41
48
|
en: 'No issues in this release.',
|
|
42
49
|
};
|
|
43
|
-
const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
50
|
+
const resolveRelease_ = async (releaseTemplates, releaseQuery, isMdx) => {
|
|
44
51
|
const query = new URLSearchParams(releaseQuery);
|
|
45
52
|
const templateName = query.get('template');
|
|
46
53
|
if (!templateName) {
|
|
@@ -93,7 +100,7 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
93
100
|
[lang]: issues.length
|
|
94
101
|
? {
|
|
95
102
|
type: 'list',
|
|
96
|
-
children: issuesToListItems(issues, lang),
|
|
103
|
+
children: issuesToListItems(issues, lang, isMdx),
|
|
97
104
|
}
|
|
98
105
|
: {
|
|
99
106
|
type: 'paragraph',
|
|
@@ -106,12 +113,12 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
106
113
|
},
|
|
107
114
|
}), {});
|
|
108
115
|
};
|
|
109
|
-
export const resolveRelease = async (releaseTemplates, releaseQuery, lang) => {
|
|
116
|
+
export const resolveRelease = async (releaseTemplates, releaseQuery, lang, isMdx) => {
|
|
110
117
|
if (releaseCache.has(releaseQuery)) {
|
|
111
118
|
const cached = await releaseCache.get(releaseQuery);
|
|
112
119
|
return cached?.[lang] ?? cached?.en;
|
|
113
120
|
}
|
|
114
|
-
const resolving = resolveRelease_(releaseTemplates, releaseQuery);
|
|
121
|
+
const resolving = resolveRelease_(releaseTemplates, releaseQuery, isMdx);
|
|
115
122
|
releaseCache.set(releaseQuery, resolving);
|
|
116
123
|
const resolved = await resolving;
|
|
117
124
|
return resolved?.[lang] ?? resolved?.en;
|
|
@@ -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`"] }));
|
|
@@ -15,6 +15,7 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, })
|
|
|
15
15
|
setOpen(open);
|
|
16
16
|
}, []);
|
|
17
17
|
useEffect(() => {
|
|
18
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
18
19
|
setOpen(expandAll);
|
|
19
20
|
}, [expandAll]);
|
|
20
21
|
const [props, required, type, schema] = useMemo(() => {
|
|
@@ -38,7 +39,7 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, })
|
|
|
38
39
|
}
|
|
39
40
|
return [props, required, type, schema];
|
|
40
41
|
}, [name, parent, property]);
|
|
41
|
-
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 &&
|
|
42
|
+
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 &&
|
|
42
43
|
Object.entries(props).map(([name, subSchema]) => (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name)))] }) }));
|
|
43
44
|
};
|
|
44
45
|
const SKIPPED_PROPERTIES = ['apiVersion', 'kind', 'metadata'];
|
|
@@ -50,7 +51,7 @@ export const K8sCrdSchema = ({ schema, version, }) => {
|
|
|
50
51
|
const toggleExpandAll = useCallback(() => {
|
|
51
52
|
setExpandAll((all) => !all);
|
|
52
53
|
}, []);
|
|
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))) }))] }));
|
|
54
|
+
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))) }))] }));
|
|
54
55
|
};
|
|
55
56
|
export const K8sCrd = ({ name, crdPath }) => {
|
|
56
57
|
const [, crd] = useMemo(() => Object.entries(crdsMap).find(([pathname, crd]) => {
|
|
@@ -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;
|
|
@@ -47,18 +47,18 @@ const RolesPermission = ({ functionResource, roleTemplates, verb, }) => {
|
|
|
47
47
|
return (_jsx(X.td, { style: TEXT_CENTER_STYLE, children: hasPermission ? '✓' : '✕' }, name));
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
|
+
const allFunctionResources = Object.values(functionResourcesMap).reduce((acc, curr) => Object.assign(acc, ...curr.map((fr) => ({ [fr.metadata.name]: fr }))), {});
|
|
50
51
|
export const K8sPermissionTable = ({ functions }) => {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [...functions]);
|
|
52
|
+
const functionResources = useMemo(() => functions.flatMap((name) => {
|
|
53
|
+
const matched = allFunctionResources[name];
|
|
54
|
+
if (!matched) {
|
|
55
|
+
console.error(`FunctionResource \`${name}\` not found!\n`);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return matched;
|
|
59
|
+
}),
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
functions);
|
|
62
62
|
const roleTemplates = useMemo(() => sortBy(Object.values(roleTemplatesMap).flat(), [
|
|
63
63
|
(it) => it.metadata.annotations['auth.cpaas.io/role.id'],
|
|
64
64
|
]), []);
|
|
@@ -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, }) => {
|
|
@@ -109,7 +111,7 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
return [];
|
|
112
|
-
}, []);
|
|
114
|
+
}, [openapiPath_, page.routePath, path]);
|
|
113
115
|
if (!pathItem || !openapi) {
|
|
114
116
|
console.error(`No OpenAPI path definition found for ${path}`);
|
|
115
117
|
return null;
|
|
@@ -43,7 +43,7 @@ export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
|
43
43
|
return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description }), extraNode] }));
|
|
44
44
|
};
|
|
45
45
|
export const OpenAPIProperties = ({ properties, openapi, }) => {
|
|
46
|
-
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property]
|
|
46
|
+
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property]) => (_jsx(X.li, { children: _jsx(OpenAPIProperty, { name: name, property: property, openapi: openapi }) }, name))) }));
|
|
47
47
|
};
|
|
48
48
|
const getRefsForSchema = (openapi, schema, knownRefs) => {
|
|
49
49
|
const refSchema = openapi.components?.schemas[schema];
|
|
@@ -85,16 +85,16 @@ export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, uid, collectRefs
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return [];
|
|
88
|
-
}, []);
|
|
89
|
-
if (!schemaItem || !openapi) {
|
|
90
|
-
console.error(`No OpenAPI schema definition found for ${schema}\n`);
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
88
|
+
}, [openapiPath_, schema]);
|
|
93
89
|
const refs = useMemo(() => {
|
|
94
|
-
if (collectRefs) {
|
|
90
|
+
if (collectRefs && openapi) {
|
|
95
91
|
return getRefsForSchema(openapi, schema, omitRoutePathRefs(page.routePath));
|
|
96
92
|
}
|
|
97
93
|
}, [collectRefs, openapi, page.routePath, schema]);
|
|
94
|
+
if (!schemaItem || !openapi) {
|
|
95
|
+
console.error(`No OpenAPI schema definition found for ${schema}\n`);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
98
|
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)))] }));
|
|
99
99
|
};
|
|
100
100
|
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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Tabs as Tabs_ } from '@rspress/core/theme';
|
|
2
|
-
import { type
|
|
3
|
-
export
|
|
2
|
+
import { type RefAttributes } from 'react';
|
|
3
|
+
export type TabsProps = Parameters<typeof Tabs_>[0] & RefAttributes<HTMLDivElement>;
|
|
4
|
+
export declare const Tabs: ({ ref, children, ...props }: TabsProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
export default Tabs;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Tabs as Tabs_ } from '@rspress/core/theme';
|
|
3
|
-
import { Children
|
|
3
|
+
import { Children } from 'react';
|
|
4
4
|
import { useIsPrint } from '../hooks/index.js';
|
|
5
|
-
export const Tabs =
|
|
5
|
+
export const Tabs = ({ ref, children, ...props }) => {
|
|
6
6
|
const isPrint = useIsPrint();
|
|
7
|
-
return (_jsx("div", { className: "doom-tabs", ref: ref, children: isPrint ? (
|
|
8
|
-
|
|
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 })) }));
|
|
12
|
+
};
|
|
9
13
|
export default Tabs;
|
|
@@ -6,7 +6,9 @@ export const TermsTable = ({ terms }) => {
|
|
|
6
6
|
const t = useTranslation();
|
|
7
7
|
const normalized = terms ?? namedTermItems;
|
|
8
8
|
const withName = normalized.some(({ name }) => name);
|
|
9
|
-
const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
|
|
9
|
+
const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
|
|
10
|
+
// eslint-disable-next-line @eslint-react/no-array-index-key
|
|
11
|
+
_jsx(X.li, { children: item }, index))) })) : ('-');
|
|
10
12
|
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))) })] }));
|
|
11
13
|
};
|
|
12
14
|
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
|
}
|
|
@@ -6,13 +6,15 @@ import { X } from './_X.js';
|
|
|
6
6
|
export const HeadingTitle = ({ slug, slugger, uid, level, children, }) => {
|
|
7
7
|
const HeadingComponents = useMemo(() => {
|
|
8
8
|
return [null, X.h1, X.h2, X.h3, X.h4, X.h5, X.h6];
|
|
9
|
-
}, [
|
|
9
|
+
}, []);
|
|
10
10
|
const HeadingComponent = HeadingComponents[level];
|
|
11
|
-
const slugFromChildren = useMemo(() =>
|
|
11
|
+
const slugFromChildren = useMemo(() =>
|
|
12
|
+
// eslint-disable-next-line @eslint-react/no-children-to-array
|
|
13
|
+
Children.toArray(children)
|
|
12
14
|
.filter((it) => typeof it === 'string')
|
|
13
15
|
.join(''), [children]);
|
|
14
16
|
const id = useMemo(() => [uid, slug || slugger?.slug(slugFromChildren)]
|
|
15
17
|
.filter(Boolean)
|
|
16
|
-
.join('-') || undefined, [slug,
|
|
18
|
+
.join('-') || undefined, [uid, slug, slugger, slugFromChildren]);
|
|
17
19
|
return (_jsxs(HeadingComponent, { id: id, children: [children, _jsx(X.a, { className: "header-anchor", href: `#${id}`, "aria-hidden": true, children: "#" })] }));
|
|
18
20
|
};
|
|
@@ -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": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@inquirer/prompts": "^7.5.3",
|
|
40
40
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
41
41
|
"@playwright/browser-chromium": "^1.52.0",
|
|
42
|
-
"@rsbuild/plugin-sass": "^1.3.
|
|
42
|
+
"@rsbuild/plugin-sass": "^1.3.2",
|
|
43
43
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
44
44
|
"@rspress/core": "2.0.0-beta.10",
|
|
45
45
|
"@rspress/plugin-algolia": "2.0.0-beta.10",
|
|
46
46
|
"@rspress/plugin-llms": "^2.0.0-beta.10",
|
|
47
|
-
"@shikijs/transformers": "^3.
|
|
47
|
+
"@shikijs/transformers": "^3.5.0",
|
|
48
48
|
"chokidar": "^4.0.3",
|
|
49
49
|
"cli-progress": "^3.12.0",
|
|
50
50
|
"clsx": "^2.1.1",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"remark-gfm": "^4.0.1",
|
|
71
71
|
"remark-mdx": "^3.1.0",
|
|
72
72
|
"remark-stringify": "^11.0.0",
|
|
73
|
-
"shiki": "^3.
|
|
73
|
+
"shiki": "^3.5.0",
|
|
74
74
|
"simple-git": "^3.27.0",
|
|
75
75
|
"swagger2openapi": "^7.0.8",
|
|
76
76
|
"tinyglobby": "^0.2.14",
|