@alauda/doom 0.8.0 → 0.8.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/runtime/components/AcpApisOverview.d.ts +2 -0
- package/lib/runtime/components/AcpApisOverview.js +4 -0
- package/lib/runtime/components/Callouts.js +1 -1
- package/lib/runtime/components/ExternalApisOverview.d.ts +3 -0
- package/lib/runtime/components/ExternalApisOverview.js +4 -0
- package/lib/runtime/components/ExternalSite.d.ts +2 -5
- package/lib/runtime/components/ExternalSite.js +2 -27
- package/lib/runtime/components/ExternalSiteLink.js +5 -2
- package/lib/runtime/components/K8sCrd.d.ts +2 -2
- package/lib/runtime/components/K8sCrd.js +9 -12
- package/lib/runtime/components/_ExternalSiteBase.d.ts +11 -0
- package/lib/runtime/components/_ExternalSiteBase.js +36 -0
- package/lib/runtime/components/index.d.ts +2 -0
- package/lib/runtime/components/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const Callouts = ({ children }) => {
|
|
3
|
-
return _jsx("
|
|
3
|
+
return _jsx("div", { className: "my-4 leading-7 doom-callouts", children: children });
|
|
4
4
|
};
|
|
5
5
|
export default Callouts;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
1
2
|
export interface ExternalSiteProps {
|
|
2
3
|
name: string;
|
|
3
4
|
}
|
|
4
|
-
export
|
|
5
|
-
name: string;
|
|
6
|
-
displayName: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const ExternalSite: ({ name }: ExternalSiteProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const ExternalSite: FC<ExternalSiteProps>;
|
|
9
6
|
export default ExternalSite;
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { handleCJKWhitespaces } from '../utils.js';
|
|
5
|
-
import { Directive } from './Directive.js';
|
|
6
|
-
import { ExternalSiteLink } from './ExternalSiteLink.js';
|
|
7
|
-
const Notes = {
|
|
8
|
-
en({ name, displayName }) {
|
|
9
|
-
return (_jsxs(_Fragment, { children: ["Because ", displayName, " releases on a different cadence from Alauda Container Platform, the ", displayName, " documentation is now available as a separate documentation set at", ' ', _jsx(ExternalSiteLink, { name: name, children: displayName }), "."] }));
|
|
10
|
-
},
|
|
11
|
-
zh({ name, displayName }) {
|
|
12
|
-
const displayName_ = handleCJKWhitespaces(displayName);
|
|
13
|
-
return (_jsxs(_Fragment, { children: ["\u56E0\u4E3A", displayName_, "\u7684\u53D1\u7248\u5468\u671F\u4E0E\u7075\u96C0\u4E91\u5BB9\u5668\u5E73\u53F0\u4E0D\u540C\uFF0C\u6240\u4EE5", displayName_, "\u7684\u6587\u6863\u73B0\u5728\u4F5C\u4E3A\u72EC\u7ACB\u7684\u6587\u6863\u7AD9\u70B9\u6258\u7BA1\u5728", displayName_.startsWith(' ') ? ' ' : '', _jsx(ExternalSiteLink, { name: name, children: displayName }), "\u3002"] }));
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
export const ExternalSite = ({ name }) => {
|
|
17
|
-
const { siteData, page } = usePageData();
|
|
18
|
-
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
19
|
-
const fallbackLang = siteData.lang || 'zh';
|
|
20
|
-
const lang = useLang() || fallbackLang;
|
|
21
|
-
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.[fallbackLang] || name, []);
|
|
22
|
-
if (!site) {
|
|
23
|
-
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
24
|
-
}
|
|
25
|
-
const Note = Notes[lang] || Notes[fallbackLang] || Notes.en;
|
|
26
|
-
return (_jsx(Directive, { title: "Note", children: _jsx(Note, { name: name, displayName: displayName }) }));
|
|
27
|
-
};
|
|
1
|
+
import { ExternalSiteBase } from './_ExternalSiteBase.js';
|
|
2
|
+
export const ExternalSite = ExternalSiteBase;
|
|
28
3
|
export default ExternalSite;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { usePageData } from '@rspress/core/runtime';
|
|
2
|
+
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
3
3
|
import { addTrailingSlash, isExternalUrl, removeLeadingSlash, } from '@rspress/shared';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useMemo } from 'react';
|
|
@@ -9,6 +9,7 @@ import classes from '../../../styles/link.module.scss';
|
|
|
9
9
|
export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
10
10
|
const { page } = usePageData();
|
|
11
11
|
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
12
|
+
const lang = useLang();
|
|
12
13
|
if (!site) {
|
|
13
14
|
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
14
15
|
}
|
|
@@ -18,6 +19,8 @@ export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
|
18
19
|
const siteBase = addTrailingSlash(site.base);
|
|
19
20
|
return (_jsx("a", { href: (page.v
|
|
20
21
|
? addTrailingSlash(siteBase + normalizeVersion(site.version))
|
|
21
|
-
: siteBase) +
|
|
22
|
+
: siteBase) +
|
|
23
|
+
(lang ? `${lang}/` : '') +
|
|
24
|
+
removeLeadingSlash(href), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'cursor-pointer', className), ...props }));
|
|
22
25
|
};
|
|
23
26
|
export default ExternalSiteLink;
|
|
@@ -12,11 +12,11 @@ export interface K8sCrdProps {
|
|
|
12
12
|
*/
|
|
13
13
|
crdPath?: string;
|
|
14
14
|
}
|
|
15
|
-
export declare const K8sCrdSchemaPart: ({ name, parent, schema: property,
|
|
15
|
+
export declare const K8sCrdSchemaPart: ({ name, parent, schema: property, expandAll, }: {
|
|
16
16
|
name: string;
|
|
17
17
|
parent: OpenAPIV3_1.SchemaObject;
|
|
18
18
|
schema: OpenAPIV3_1.SchemaObject;
|
|
19
|
-
|
|
19
|
+
expandAll: boolean;
|
|
20
20
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
export declare const K8sCrdSchema: ({ schema, version, }: {
|
|
22
22
|
schema: OpenAPIV3_1.SchemaObject;
|
|
@@ -9,14 +9,14 @@ import { useTranslation } from '../hooks/index.js';
|
|
|
9
9
|
import { Directive } from './Directive.js';
|
|
10
10
|
import { Markdown } from './_Markdown.js';
|
|
11
11
|
const X = getCustomMDXComponent();
|
|
12
|
-
export const K8sCrdSchemaPart = ({ name, parent, schema: property,
|
|
13
|
-
const [open, setOpen] = useState(
|
|
12
|
+
export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, }) => {
|
|
13
|
+
const [open, setOpen] = useState(expandAll);
|
|
14
14
|
const onToggle = useCallback((open) => {
|
|
15
15
|
setOpen(open);
|
|
16
16
|
}, []);
|
|
17
17
|
useEffect(() => {
|
|
18
|
-
setOpen(
|
|
19
|
-
}, [
|
|
18
|
+
setOpen(expandAll);
|
|
19
|
+
}, [expandAll]);
|
|
20
20
|
const [props, required, type, schema] = useMemo(() => {
|
|
21
21
|
let schema = property;
|
|
22
22
|
let props = property.properties;
|
|
@@ -39,20 +39,17 @@ export const K8sCrdSchemaPart = ({ name, parent, schema: property, openAll, }) =
|
|
|
39
39
|
return [props, required, type, schema];
|
|
40
40
|
}, [name, parent, property]);
|
|
41
41
|
return (_jsx(_Fragment, { children: _jsxs(Directive, { type: "details", title: _jsxs(_Fragment, { children: [name, type && _jsx(X.code, { children: type }), required && _jsx(Badge, { children: "required" })] }), open: open, onToggle: onToggle, children: [_jsx(Markdown, { children: schema.description }), props &&
|
|
42
|
-
Object.entries(props).map(([name, subSchema]) => (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema,
|
|
42
|
+
Object.entries(props).map(([name, subSchema]) => (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name)))] }) }));
|
|
43
43
|
};
|
|
44
44
|
const SKIPPED_PROPERTIES = ['apiVersion', 'kind', 'metadata'];
|
|
45
45
|
export const K8sCrdSchema = ({ schema, version, }) => {
|
|
46
46
|
const { description, properties } = schema;
|
|
47
47
|
const t = useTranslation();
|
|
48
|
-
const [
|
|
49
|
-
const
|
|
50
|
-
|
|
48
|
+
const [expandAll, setExpandAll] = useState(false);
|
|
49
|
+
const toggleExpandAll = useCallback(() => {
|
|
50
|
+
setExpandAll((all) => !all);
|
|
51
51
|
}, []);
|
|
52
|
-
|
|
53
|
-
setOpenAll(false);
|
|
54
|
-
}, []);
|
|
55
|
-
return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx(X.code, { children: version }), _jsx(Badge, { children: "version" })] }), properties != null && (_jsxs("div", { className: "ml-auto", children: [_jsx(Button, { className: "doom-btn", type: "button", text: _jsxs("span", { onClick: collapseAll, children: ["- ", t('collapse_all')] }), size: "medium", theme: "alt" }), _jsx(Button, { className: "doom-btn ml-2", type: "button", text: _jsxs("span", { onClick: expandAll, children: ["+ ", t('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, openAll: openAll }, name))) }))] }));
|
|
52
|
+
return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "flex items-center", children: [_jsxs("span", { children: [_jsx(X.code, { children: version }), _jsx(Badge, { children: "version" })] }), 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))) }))] }));
|
|
56
53
|
};
|
|
57
54
|
export const K8sCrd = ({ name, crdPath }) => {
|
|
58
55
|
const { page } = usePageData();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface ExternalSiteBaseProps {
|
|
3
|
+
name: string;
|
|
4
|
+
template?: 'apisOverview';
|
|
5
|
+
}
|
|
6
|
+
export interface ExternalSiteNoteProps {
|
|
7
|
+
name: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export type Notes = Partial<Record<string, FC<ExternalSiteNoteProps>>>;
|
|
11
|
+
export declare const ExternalSiteBase: ({ name, template }: ExternalSiteBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { handleCJKWhitespaces } from '../utils.js';
|
|
5
|
+
import Directive from './Directive.js';
|
|
6
|
+
import ExternalSiteLink from './ExternalSiteLink.js';
|
|
7
|
+
const SiteNotes = {
|
|
8
|
+
en({ name, displayName }) {
|
|
9
|
+
return (_jsxs(_Fragment, { children: ["Because ", displayName, " releases on a different cadence from Alauda Container Platform, the ", displayName, " documentation is now available as a separate documentation set at", ' ', _jsx(ExternalSiteLink, { name: name, children: displayName }), "."] }));
|
|
10
|
+
},
|
|
11
|
+
zh({ name, displayName }) {
|
|
12
|
+
const displayName_ = handleCJKWhitespaces(displayName);
|
|
13
|
+
return (_jsxs(_Fragment, { children: ["\u56E0\u4E3A", displayName_, "\u7684\u53D1\u7248\u5468\u671F\u4E0E\u7075\u96C0\u4E91\u5BB9\u5668\u5E73\u53F0\u4E0D\u540C\uFF0C\u6240\u4EE5", displayName_, "\u7684\u6587\u6863\u73B0\u5728\u4F5C\u4E3A\u72EC\u7ACB\u7684\u6587\u6863\u7AD9\u70B9\u6258\u7BA1\u5728", displayName_.startsWith(' ') ? ' ' : '', _jsx(ExternalSiteLink, { name: name, children: displayName }), "\u3002"] }));
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const ApisOverviewNotes = {
|
|
17
|
+
en({ name, displayName }) {
|
|
18
|
+
return (_jsxs(_Fragment, { children: ["For the introduction to the usage methods of ", displayName, " APIs, please refer to", ' ', _jsxs(ExternalSiteLink, { name: name, href: "apis/overview/", children: [displayName, " APIs Guide"] }), "."] }));
|
|
19
|
+
},
|
|
20
|
+
zh({ name, displayName }) {
|
|
21
|
+
const displayName_ = handleCJKWhitespaces(displayName);
|
|
22
|
+
return (_jsxs(_Fragment, { children: ["\u5173\u4E8E", displayName_, " APIs \u7684\u4F7F\u7528\u65B9\u6CD5\u4ECB\u7ECD\u8BF7\u53C2\u8003", displayName_.startsWith(' ') ? ' ' : '', _jsxs(ExternalSiteLink, { name: name, href: "apis/overview/", children: [displayName, " APIs \u6307\u5357"] }), "\u3002"] }));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const ExternalSiteBase = ({ name, template }) => {
|
|
26
|
+
const { siteData, page } = usePageData();
|
|
27
|
+
const site = useMemo(() => page.sites?.find((s) => s.name === name), []);
|
|
28
|
+
const lang = useLang() || siteData.lang || 'zh';
|
|
29
|
+
const displayName = useMemo(() => site?.displayName?.[lang] || site?.displayName?.en || name.toUpperCase(), []);
|
|
30
|
+
if (!site) {
|
|
31
|
+
return (_jsxs(Directive, { type: "danger", children: ["No site with name `", name, "` found, please ensure it's already defined at `sites.yaml`"] }));
|
|
32
|
+
}
|
|
33
|
+
const Notes = template === 'apisOverview' ? ApisOverviewNotes : SiteNotes;
|
|
34
|
+
const Note = Notes[lang] || Notes.en;
|
|
35
|
+
return (_jsx(Directive, { title: "Note", children: _jsx(Note, { name: name, displayName: displayName }) }));
|
|
36
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './AcpApisOverview.js';
|
|
1
2
|
export * from './Badge.js';
|
|
2
3
|
export * from './Callouts.js';
|
|
3
4
|
export * from './Card.js';
|
|
4
5
|
export * from './Directive.js';
|
|
6
|
+
export * from './ExternalApisOverview.js';
|
|
5
7
|
export * from './ExternalSite.js';
|
|
6
8
|
export * from './ExternalSiteLink.js';
|
|
7
9
|
export * from './JsonViewer.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from './AcpApisOverview.js';
|
|
1
2
|
export * from './Badge.js';
|
|
2
3
|
export * from './Callouts.js';
|
|
3
4
|
export * from './Card.js';
|
|
4
5
|
export * from './Directive.js';
|
|
6
|
+
export * from './ExternalApisOverview.js';
|
|
5
7
|
export * from './ExternalSite.js';
|
|
6
8
|
export * from './ExternalSiteLink.js';
|
|
7
9
|
export * from './JsonViewer.js';
|