@alauda/doom 0.8.4 → 0.8.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/global/VersionsNav/index.js +6 -1
- package/lib/plugins/global/index.d.ts +1 -1
- package/lib/plugins/global/index.js +7 -1
- package/lib/runtime/components/ExternalSiteLink.js +1 -5
- package/lib/runtime/components/_BrandBase.js +2 -1
- package/lib/runtime/hooks/useSiteOverrides.js +15 -5
- package/lib/runtime/utils.d.ts +1 -1
- package/lib/runtime/utils.js +3 -0
- package/package.json +2 -2
|
@@ -5,7 +5,12 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { parse } from 'yaml';
|
|
7
7
|
import { NavMenuGroup } from './NavMenuGroup.js';
|
|
8
|
-
const getNavMenu = () =>
|
|
8
|
+
const getNavMenu = () => {
|
|
9
|
+
if (typeof document === 'undefined') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return document.querySelector('.rspress-nav-menu');
|
|
13
|
+
};
|
|
9
14
|
export const VersionsNav = () => {
|
|
10
15
|
const { siteData, page } = usePageData();
|
|
11
16
|
const [versionsBase, version] = useMemo(() => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { addTrailingSlash } from '@rspress/core';
|
|
3
4
|
import { baseResolve, pkgResolve } from '../../utils/index.js';
|
|
5
|
+
import { normalizeVersion } from '../../shared/helpers.js';
|
|
4
6
|
const globalComponentsDir = baseResolve('global');
|
|
5
7
|
const componentsDir = baseResolve('runtime/components');
|
|
6
8
|
export const globalPlugin = ({ sites, version, } = {}) => {
|
|
@@ -22,7 +24,11 @@ export const globalPlugin = ({ sites, version, } = {}) => {
|
|
|
22
24
|
.map((file) => path.resolve(componentsDir, file)),
|
|
23
25
|
},
|
|
24
26
|
extendPageData(pageData) {
|
|
25
|
-
pageData.sites = sites
|
|
27
|
+
pageData.sites = sites?.map((site) => ({
|
|
28
|
+
...site,
|
|
29
|
+
base: addTrailingSlash(site.base || (site.name === 'acp' ? '/container-platform' : '')),
|
|
30
|
+
version: normalizeVersion(site.version),
|
|
31
|
+
}));
|
|
26
32
|
pageData.v = version === 'unversioned' ? undefined : version;
|
|
27
33
|
},
|
|
28
34
|
};
|
|
@@ -3,7 +3,6 @@ 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';
|
|
6
|
-
import { normalizeVersion } from '../../shared/index.js';
|
|
7
6
|
import { Directive } from './Directive.js';
|
|
8
7
|
import classes from '../../../styles/link.module.scss';
|
|
9
8
|
export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
@@ -16,10 +15,7 @@ export const ExternalSiteLink = ({ name, href = '', className, ...props }) => {
|
|
|
16
15
|
if (isExternalUrl(href)) {
|
|
17
16
|
return _jsxs(Directive, { type: "danger", children: ["Invalid href `", href, "` found"] });
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
return (_jsx("a", { href: (page.v
|
|
21
|
-
? addTrailingSlash(siteBase + normalizeVersion(site.version))
|
|
22
|
-
: siteBase) +
|
|
18
|
+
return (_jsx("a", { href: (page.v ? addTrailingSlash(site.base + site.version) : site.base) +
|
|
23
19
|
(lang ? `${lang}/` : '') +
|
|
24
20
|
removeLeadingSlash(href), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'cursor-pointer', className), ...props }));
|
|
25
21
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useSiteOverrides } from '../hooks/index.js';
|
|
3
|
+
import { handleCJKWhitespaces } from '../utils.js';
|
|
3
4
|
export const BrandBase = ({ type }) => {
|
|
4
5
|
const { brand } = useSiteOverrides();
|
|
5
|
-
return _jsx(_Fragment, { children: brand?.[type] });
|
|
6
|
+
return _jsx(_Fragment, { children: handleCJKWhitespaces(brand?.[type]) });
|
|
6
7
|
};
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { addTrailingSlash } from '@rspress/shared';
|
|
2
1
|
import { isProduction, useLang, usePageData } from '@rspress/core/runtime';
|
|
3
2
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
3
|
import { parse } from 'yaml';
|
|
5
|
-
|
|
4
|
+
const DEFAULT_SITE_BRAND = {
|
|
5
|
+
en: {
|
|
6
|
+
company: 'Alauda',
|
|
7
|
+
product: 'Alauda Container Platform',
|
|
8
|
+
productShort: 'ACP',
|
|
9
|
+
},
|
|
10
|
+
zh: {
|
|
11
|
+
company: '灵雀云',
|
|
12
|
+
product: '灵雀云容器平台',
|
|
13
|
+
productShort: 'ACP',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
6
16
|
let siteOverrides;
|
|
7
17
|
let promise;
|
|
8
18
|
const fetchSiteOverrides = async (base, version, acpSite) => {
|
|
9
19
|
if (promise) {
|
|
10
20
|
return promise;
|
|
11
21
|
}
|
|
12
|
-
const acpSiteOverridesUrl = acpSite
|
|
13
|
-
? `${
|
|
22
|
+
const acpSiteOverridesUrl = acpSite && isProduction()
|
|
23
|
+
? `${acpSite.base}${version ? acpSite.version + '/' : ''}overrides.yaml`
|
|
14
24
|
: null;
|
|
15
25
|
const siteOverridesUrl = `${isProduction() ? base : '/'}overrides.yaml`;
|
|
16
26
|
const urls = [acpSiteOverridesUrl];
|
|
@@ -32,7 +42,7 @@ const fetchSiteOverrides = async (base, version, acpSite) => {
|
|
|
32
42
|
//
|
|
33
43
|
}
|
|
34
44
|
})).then(([acpSiteOverrides, siteOverrides]) => (siteOverrides = {
|
|
35
|
-
brand: acpSiteOverrides?.brand,
|
|
45
|
+
brand: acpSiteOverrides?.brand ?? DEFAULT_SITE_BRAND,
|
|
36
46
|
...siteOverrides,
|
|
37
47
|
}))).catch(() => ({}));
|
|
38
48
|
};
|
package/lib/runtime/utils.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export declare const omitRoutePathRefs: (refs: Record<string, string>, routePath
|
|
|
8
8
|
[k: string]: string;
|
|
9
9
|
};
|
|
10
10
|
export declare const CJK_PATTERN: RegExp;
|
|
11
|
-
export declare const handleCJKWhitespaces: (text
|
|
11
|
+
export declare const handleCJKWhitespaces: (text?: string) => string;
|
package/lib/runtime/utils.js
CHANGED
|
@@ -19,6 +19,9 @@ export const DEFAULT_COMMON_REFS = Object.fromEntries(Object.entries(DEFAULT_COM
|
|
|
19
19
|
export const omitRoutePathRefs = (refs, routePath) => Object.fromEntries(Object.entries(refs).filter(([, value]) => routePath !== value.split('#')[0]));
|
|
20
20
|
export const CJK_PATTERN = /\p{sc=Han}/u;
|
|
21
21
|
export const handleCJKWhitespaces = (text) => {
|
|
22
|
+
if (!text) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
22
25
|
text = text.at(0)?.match(CJK_PATTERN) ? text : ` ${text}`;
|
|
23
26
|
return text.at(-1)?.match(CJK_PATTERN) ? text : `${text} `;
|
|
24
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/swagger2openapi": "^7.0.4",
|
|
76
76
|
"@unts/patch-package": "^8.0.0",
|
|
77
77
|
"eslint": "^9.18.0",
|
|
78
|
-
"lint-staged": "^15.4.
|
|
78
|
+
"lint-staged": "^15.4.1",
|
|
79
79
|
"npm-run-all2": "^7.0.2",
|
|
80
80
|
"prettier": "^3.4.2",
|
|
81
81
|
"prettier-plugin-pkg": "^0.18.1",
|