@alauda/doom 0.14.4 → 0.14.5
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/load-config.js +1 -1
- package/lib/global/SiteOverrides/index.d.ts +1 -1
- package/lib/global/SiteOverrides/index.js +0 -1
- package/lib/global/VersionsNav/NavMenuGroup.js +3 -5
- package/lib/global/VersionsNav/NavMenuSingleItem.js +2 -2
- package/lib/global/VersionsNav/index.d.ts +1 -1
- package/lib/global/VersionsNav/index.js +32 -12
- package/lib/plugins/global/index.d.ts +1 -0
- package/lib/plugins/global/index.js +3 -2
- package/lib/runtime/components/TermsTable.js +2 -2
- package/lib/runtime/hooks/useSiteOverrides.js +2 -2
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +2 -2
- package/lib/runtime/translation.js +2 -2
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/constants.js +1 -0
- package/lib/shared/index.d.ts +1 -0
- package/lib/shared/index.js +1 -0
- package/lib/terms.d.ts +4 -2
- package/lib/terms.js +4 -1
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/cli/load-config.js
CHANGED
|
@@ -185,7 +185,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
185
185
|
root: commonConfig.root,
|
|
186
186
|
});
|
|
187
187
|
if (base && prefix) {
|
|
188
|
-
mergedConfig.base = normalizeSlash(prefix) + base;
|
|
188
|
+
mergedConfig.base = (mergedConfig.prefix = normalizeSlash(prefix)) + base;
|
|
189
189
|
}
|
|
190
190
|
let ensureDefaultLogo = false;
|
|
191
191
|
if (!mergedConfig.logo) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SiteOverrides: () =>
|
|
1
|
+
export declare const SiteOverrides: () => void;
|
|
2
2
|
export default SiteOverrides;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Tag } from '@rspress/core/theme';
|
|
3
|
-
import { withoutBase, } from '@rspress/shared';
|
|
3
|
+
import { isExternalUrl, withoutBase, } from '@rspress/shared';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { SvgDown } from './Down.js';
|
|
6
6
|
import { NavMenuSingleItem, } from './NavMenuSingleItem.js';
|
|
@@ -11,7 +11,7 @@ function ActiveGroupItem({ item }) {
|
|
|
11
11
|
}, children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { className: "text-brand", children: item.text })] }, item.link));
|
|
12
12
|
}
|
|
13
13
|
function NormalGroupItem({ item }) {
|
|
14
|
-
return (_jsx("div", { className: "font-medium my-1", children: _jsx("a", { href: item.link, children: _jsx("div", { className: "rounded-2xl hover:bg-mute", style: {
|
|
14
|
+
return (_jsx("div", { className: "font-medium my-1", children: _jsx("a", { href: item.link, target: isExternalUrl(item.link) ? '_blank' : undefined, rel: "noopener noreferrer", children: _jsx("div", { className: "rounded-2xl hover:bg-mute", style: {
|
|
15
15
|
padding: '0.4rem 1.5rem 0.4rem 0.75rem',
|
|
16
16
|
}, children: _jsxs("div", { className: "flex", children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { children: item.text })] }) }) }) }, item.link));
|
|
17
17
|
}
|
|
@@ -45,7 +45,5 @@ export function NavMenuGroup(item) {
|
|
|
45
45
|
border: '1px solid var(--rp-c-divider-light)',
|
|
46
46
|
borderRadius: 'var(--rp-radius-large)',
|
|
47
47
|
background: 'var(--rp-c-bg)',
|
|
48
|
-
}, children: groupItems.map((item) => {
|
|
49
|
-
return (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text));
|
|
50
|
-
}) }) })] }));
|
|
48
|
+
}, children: groupItems.map((item) => (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text))) }) })] }));
|
|
51
49
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Tag } from '@rspress/core/theme';
|
|
3
|
-
import { withoutBase } from '@rspress/shared';
|
|
3
|
+
import { isExternalUrl, withoutBase, } from '@rspress/shared';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import styles from '../../../styles/versions-nav.module.scss';
|
|
6
6
|
export function NavMenuSingleItem({ activeMatch, base, compact, download, link, pathname, rightIcon, text, tag, }) {
|
|
7
7
|
const isActive = useMemo(() => !!base &&
|
|
8
8
|
!!pathname &&
|
|
9
9
|
new RegExp(activeMatch || link).test(withoutBase(pathname, base)), [activeMatch, base, link, pathname]);
|
|
10
|
-
return (_jsx("a", { href: link, download: download, children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} text-sm font-medium ${compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`, children: [_jsx(Tag, { tag: tag }), text, rightIcon] }) }));
|
|
10
|
+
return (_jsx("a", { href: link, download: download, target: isExternalUrl(link) ? '_blank' : undefined, rel: "noopener noreferrer", children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} text-sm font-medium ${compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`, children: [_jsx(Tag, { tag: tag }), text, rightIcon] }) }, link));
|
|
11
11
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VersionsNav: () => import("react").
|
|
1
|
+
export declare const VersionsNav: () => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default VersionsNav;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation } from '@alauda/doom/runtime';
|
|
3
|
-
import { isProduction, removeTrailingSlash, useLang, usePageData, } from '@rspress/core/runtime';
|
|
3
|
+
import { isProduction, NoSSR, removeTrailingSlash, useLang, usePageData, } from '@rspress/core/runtime';
|
|
4
4
|
import { noop } from 'es-toolkit';
|
|
5
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { parse } from 'yaml';
|
|
8
|
-
import { getPdfName } from '../../shared/index.js';
|
|
8
|
+
import { ACP_BASE, getPdfName } from '../../shared/index.js';
|
|
9
9
|
import { NavMenuGroup } from './NavMenuGroup.js';
|
|
10
10
|
import { NavMenuSingleItem } from './NavMenuSingleItem.js';
|
|
11
11
|
import virtual from 'doom-@global-virtual';
|
|
@@ -15,7 +15,16 @@ const getNavMenu = () => {
|
|
|
15
15
|
}
|
|
16
16
|
return document.querySelector('.rspress-nav-menu');
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const LEGACY_VERSIONS = ['v3.18.1', 'v3.18.0', 'v3.16', 'v3.14'];
|
|
19
|
+
const LEGACY_NAV_ITEMS = LEGACY_VERSIONS.map((v) => ({
|
|
20
|
+
text: v,
|
|
21
|
+
link: `https://docs.alauda.io/document/release-notes?version=${v}`,
|
|
22
|
+
}));
|
|
23
|
+
const ALLOW_LEGACY_DOMAINS = ['docs.alauda.cn', 'docs.alauda.io'];
|
|
24
|
+
if (!isProduction()) {
|
|
25
|
+
ALLOW_LEGACY_DOMAINS.push('localhost');
|
|
26
|
+
}
|
|
27
|
+
const VersionsNav_ = () => {
|
|
19
28
|
const { siteData } = usePageData();
|
|
20
29
|
const lang = useLang();
|
|
21
30
|
const t = useTranslation();
|
|
@@ -42,15 +51,18 @@ export const VersionsNav = () => {
|
|
|
42
51
|
return;
|
|
43
52
|
}
|
|
44
53
|
const res = await fetch(`${isProduction() ? versionsBase : ''}/versions.yaml`);
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
45
57
|
const text = await res.text();
|
|
46
|
-
setNavMenu(getNavMenu());
|
|
47
58
|
const versions = parse(text);
|
|
48
59
|
if (version && !versions.includes(version)) {
|
|
49
60
|
versions.unshift(version);
|
|
50
61
|
}
|
|
51
62
|
setVersions(versions);
|
|
63
|
+
setNavMenu(getNavMenu);
|
|
52
64
|
};
|
|
53
|
-
fetchVersions().catch(noop);
|
|
65
|
+
void fetchVersions().catch(noop);
|
|
54
66
|
}, []);
|
|
55
67
|
// hack way to detect nav menu recreation on theme change
|
|
56
68
|
useEffect(() => {
|
|
@@ -67,16 +79,24 @@ export const VersionsNav = () => {
|
|
|
67
79
|
observer.disconnect();
|
|
68
80
|
};
|
|
69
81
|
}, [navMenu]);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
const navItems = useMemo(() => {
|
|
83
|
+
const versionItems = (versions || []).map((v) => ({
|
|
84
|
+
text: v,
|
|
85
|
+
link: `${versionsBase}/${v}/`,
|
|
86
|
+
activeMatch: v,
|
|
87
|
+
}));
|
|
88
|
+
if (ALLOW_LEGACY_DOMAINS.includes(location.hostname) &&
|
|
89
|
+
virtual.userBase === ACP_BASE) {
|
|
90
|
+
versionItems.push(...LEGACY_NAV_ITEMS);
|
|
91
|
+
}
|
|
92
|
+
return versionItems;
|
|
93
|
+
}, [versionsBase, versions]);
|
|
75
94
|
let finalNavMenu;
|
|
76
|
-
if ((!
|
|
95
|
+
if ((!navItems.length && !virtual.download) ||
|
|
77
96
|
!(finalNavMenu = getNavMenu())) {
|
|
78
97
|
return;
|
|
79
98
|
}
|
|
80
|
-
return createPortal(_jsxs(_Fragment, { children: [downloadLink && (_jsx(NavMenuSingleItem, { text: t('
|
|
99
|
+
return createPortal(_jsxs(_Fragment, { children: [downloadLink && (_jsx(NavMenuSingleItem, { text: t('download_pdf'), link: downloadLink, download: true })), !navItems.length || (_jsx(NavMenuGroup, { text: version, base: versionsBase, items: navItems, pathname: siteData.base }))] }), finalNavMenu);
|
|
81
100
|
};
|
|
101
|
+
export const VersionsNav = () => (_jsx(NoSSR, { children: _jsx(VersionsNav_, {}) }));
|
|
82
102
|
export default VersionsNav;
|
|
@@ -6,6 +6,7 @@ export interface GlobalPluginOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export interface GlobalVirtual extends GlobalPluginOptions {
|
|
8
8
|
userBase?: string;
|
|
9
|
+
prefix?: string;
|
|
9
10
|
sites?: DoomSite[];
|
|
10
11
|
}
|
|
11
12
|
export declare const globalPlugin: ({ version, download, }: GlobalPluginOptions) => RspressPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { addTrailingSlash } from '@rspress/core';
|
|
4
|
+
import { ACP_BASE, normalizeVersion, } from '../../shared/index.js';
|
|
4
5
|
import { baseResolve, pkgResolve } from '../../utils/index.js';
|
|
5
|
-
import { normalizeVersion } from '../../shared/index.js';
|
|
6
6
|
const globalComponentsDir = baseResolve('global');
|
|
7
7
|
const componentsDir = baseResolve('runtime/components');
|
|
8
8
|
export const globalPlugin = ({ version, download, }) => {
|
|
@@ -27,11 +27,12 @@ export const globalPlugin = ({ version, download, }) => {
|
|
|
27
27
|
return {
|
|
28
28
|
'doom-@global-virtual': `export default ${JSON.stringify({
|
|
29
29
|
userBase: config.userBase,
|
|
30
|
+
prefix: config.prefix,
|
|
30
31
|
version: version === 'unversioned' ? undefined : version,
|
|
31
32
|
download,
|
|
32
33
|
sites: config.sites?.map((site) => ({
|
|
33
34
|
...site,
|
|
34
|
-
base: addTrailingSlash(site.base || (site.name === 'acp' ?
|
|
35
|
+
base: addTrailingSlash(site.base || (site.name === 'acp' ? ACP_BASE : '')),
|
|
35
36
|
version: normalizeVersion(site.version),
|
|
36
37
|
})),
|
|
37
38
|
}, null, isProd ? 0 : 2)}`,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { useTranslation } from '../hooks/index.js';
|
|
4
2
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
|
3
|
+
import { useState } from 'react';
|
|
5
4
|
import { allTermItems, namedTermItems, unnamedTermItems, } from '../../terms.js';
|
|
5
|
+
import { useTranslation } from '../hooks/index.js';
|
|
6
6
|
export const TermsTable = ({ named }) => {
|
|
7
7
|
const [X] = useState(getCustomMDXComponent);
|
|
8
8
|
const t = useTranslation();
|
|
@@ -22,7 +22,7 @@ const fetchSiteOverrides = async (base, version, acpSite) => {
|
|
|
22
22
|
return promise;
|
|
23
23
|
}
|
|
24
24
|
const acpSiteOverridesUrl = acpSite && isProduction()
|
|
25
|
-
? `${acpSite.base}${version ? acpSite.version + '/' : ''}overrides.yaml`
|
|
25
|
+
? `${(virtual.prefix || '') + acpSite.base}${version ? acpSite.version + '/' : ''}overrides.yaml`
|
|
26
26
|
: null;
|
|
27
27
|
const siteOverridesUrl = `${isProduction() ? base : '/'}overrides.yaml`;
|
|
28
28
|
const urls = [acpSiteOverridesUrl];
|
|
@@ -45,7 +45,7 @@ const fetchSiteOverrides = async (base, version, acpSite) => {
|
|
|
45
45
|
}
|
|
46
46
|
}))
|
|
47
47
|
.then(([acpSiteOverrides, siteOverrides]) => ({
|
|
48
|
-
...siteOverrides,
|
|
48
|
+
...(urls.length === 1 ? acpSiteOverrides : siteOverrides),
|
|
49
49
|
terms: merge({}, namedTerms, acpSiteOverrides?.terms, siteOverrides?.terms),
|
|
50
50
|
}))
|
|
51
51
|
.catch(() => ({ terms: namedTerms }))
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Locale } from '../translation.js';
|
|
2
2
|
export declare const useLocale: () => Locale;
|
|
3
|
-
export declare const useTranslation: () => (key: "function" | "
|
|
3
|
+
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "create" | "update" | "view" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf") => string;
|
|
@@ -15,7 +15,7 @@ export declare const TRANSLATIONS: {
|
|
|
15
15
|
description: string;
|
|
16
16
|
chinese_bad_cases: string;
|
|
17
17
|
english_bad_cases: string;
|
|
18
|
-
|
|
18
|
+
download_pdf: string;
|
|
19
19
|
};
|
|
20
20
|
zh: {
|
|
21
21
|
collapse_all: string;
|
|
@@ -33,7 +33,7 @@ export declare const TRANSLATIONS: {
|
|
|
33
33
|
description: string;
|
|
34
34
|
chinese_bad_cases: string;
|
|
35
35
|
english_bad_cases: string;
|
|
36
|
-
|
|
36
|
+
download_pdf: string;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
export type Locale = keyof typeof TRANSLATIONS;
|
|
@@ -14,7 +14,7 @@ const en = {
|
|
|
14
14
|
description: 'Description',
|
|
15
15
|
chinese_bad_cases: 'Chinese Bad Cases',
|
|
16
16
|
english_bad_cases: 'English Bad Cases',
|
|
17
|
-
|
|
17
|
+
download_pdf: 'Download PDF',
|
|
18
18
|
};
|
|
19
19
|
const zh = {
|
|
20
20
|
collapse_all: '全部收起',
|
|
@@ -32,6 +32,6 @@ const zh = {
|
|
|
32
32
|
description: '描述',
|
|
33
33
|
chinese_bad_cases: '中文反例',
|
|
34
34
|
english_bad_cases: '英文反例',
|
|
35
|
-
|
|
35
|
+
download_pdf: '下载 PDF',
|
|
36
36
|
};
|
|
37
37
|
export const TRANSLATIONS = { en, zh };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ACP_BASE = "/container_platform/";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ACP_BASE = '/container_platform/';
|
package/lib/shared/index.d.ts
CHANGED
package/lib/shared/index.js
CHANGED
package/lib/terms.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SetOptional } from 'type-fest';
|
|
1
2
|
export interface TermItem {
|
|
2
3
|
en: string;
|
|
3
4
|
zh?: string;
|
|
@@ -27,9 +28,10 @@ declare const terms: {
|
|
|
27
28
|
export type TermName = keyof typeof terms;
|
|
28
29
|
export type NamedTerms = Record<TermName, TermItem>;
|
|
29
30
|
export interface NamedTermItem extends TermItem {
|
|
30
|
-
name
|
|
31
|
+
name: TermName;
|
|
31
32
|
}
|
|
33
|
+
export type NormalizedTermItem = SetOptional<NamedTermItem, 'name'>;
|
|
32
34
|
export declare const namedTerms: NamedTerms;
|
|
33
35
|
export declare const namedTermItems: NamedTermItem[];
|
|
34
|
-
export declare const allTermItems:
|
|
36
|
+
export declare const allTermItems: NormalizedTermItem[];
|
|
35
37
|
export {};
|
package/lib/terms.js
CHANGED
package/lib/types.d.ts
CHANGED