@alauda/doom 1.12.7 → 1.13.1
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/index.js +1 -1
- package/lib/cli/lint.js +1 -0
- package/lib/cli/load-config.js +9 -1
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/theme/EditLink.d.ts +1 -0
- package/lib/theme/EditLink.js +12 -0
- package/lib/theme/Layout.d.ts +8 -0
- package/lib/{theme.js → theme/Layout.js} +3 -24
- package/lib/theme/Search.d.ts +1 -0
- package/lib/theme/Search.js +21 -0
- package/lib/theme/index.d.ts +4 -0
- package/lib/theme/index.js +5 -0
- package/lib/theme/useEditLink.d.ts +4 -0
- package/lib/theme/useEditLink.js +22 -0
- package/package.json +17 -17
- package/styles/edit-link.module.scss +11 -0
- package/lib/theme.d.ts +0 -10
package/lib/cli/index.js
CHANGED
|
@@ -42,7 +42,7 @@ program
|
|
|
42
42
|
.option('-E, --exclude <language...>', 'Include all languages except the specific language(s), `ru` for example')
|
|
43
43
|
.option('-o, --out-dir <path>', 'Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`')
|
|
44
44
|
.option('-r, --redirect <enum>', 'Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang`', 'only-default-lang')
|
|
45
|
-
.option('-R, --edit-repo [boolean|url]', 'Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted', parseBooleanOrString, false)
|
|
45
|
+
.option('-R, --edit-repo [boolean|url|lang]', 'Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted; if a language code is provided, all other languages will use the same repo but with the language code as sub-path', parseBooleanOrString, false)
|
|
46
46
|
.option('-a, --algolia [boolean|alauda]', 'Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search', parseBooleanOrString, false)
|
|
47
47
|
.option('-S, --site-url', 'Whether to enable the siteUrl for sitemap generation', parseBoolean, false)
|
|
48
48
|
.option('-n, --no-open', 'Do not open the browser after starting the server')
|
package/lib/cli/lint.js
CHANGED
|
@@ -17,6 +17,7 @@ export const lintCommand = new Command('lint')
|
|
|
17
17
|
const eslint = new ESLint({
|
|
18
18
|
cwd: docsDir,
|
|
19
19
|
overrideConfigFile: true,
|
|
20
|
+
ignorePatterns: globalOptions.ignore ? config.internalRoutes : undefined,
|
|
20
21
|
// @ts-expect-error -- stronger types
|
|
21
22
|
overrideConfig: await doom(cspell ? config.lint?.cspellOptions : null),
|
|
22
23
|
});
|
package/lib/cli/load-config.js
CHANGED
|
@@ -75,7 +75,15 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
75
75
|
let { editRepoBaseUrl } = config;
|
|
76
76
|
const editRepoEnabled = !!editRepo;
|
|
77
77
|
if (typeof editRepo === 'string') {
|
|
78
|
-
|
|
78
|
+
if (editRepo.includes('/')) {
|
|
79
|
+
editRepoBaseUrl = editRepo;
|
|
80
|
+
}
|
|
81
|
+
else if (editRepoBaseUrl) {
|
|
82
|
+
editRepoBaseUrl = addTrailingSlash(editRepoBaseUrl);
|
|
83
|
+
if (!editRepoBaseUrl.endsWith(`/${editRepo}/`)) {
|
|
84
|
+
editRepoBaseUrl += editRepo;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
88
|
if (editRepoEnabled) {
|
|
81
89
|
if (editRepoBaseUrl) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Language } from '../../shared/index.js';
|
|
2
2
|
export declare const useLang: () => Language;
|
|
3
|
-
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip" | "customer_portal_global" | "customer_portal_china" | "user_login_region_china_tip" | "user_login_region_global_tip" | "account_id" | "username" | "
|
|
3
|
+
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "close" | "password" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip" | "customer_portal_global" | "customer_portal_china" | "user_login_region_china_tip" | "user_login_region_global_tip" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat") => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function EditLink(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEditLink } from "./useEditLink.js";
|
|
3
|
+
import classes from '@alauda/doom/styles/edit-link.module.scss';
|
|
4
|
+
export function EditLink() {
|
|
5
|
+
const editLinkObj = useEditLink();
|
|
6
|
+
if (!editLinkObj) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const { text, link } = editLinkObj;
|
|
10
|
+
// EditLink must be an external site, so we use <a> directly instead of Link
|
|
11
|
+
return (_jsx("a", { href: link, target: "_blank", className: classes.editLink, children: text }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DoomSidebarGroup, DoomSidebarItem } from '../plugins/index.ts';
|
|
2
|
+
import type { ExportItem } from '../types.ts';
|
|
3
|
+
export interface MatchedSidebar {
|
|
4
|
+
sidebar: DoomSidebarGroup | DoomSidebarItem;
|
|
5
|
+
exportItem: ExportItem;
|
|
6
|
+
depth: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const Layout: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLang, useSite, withBase } from '@rspress/core/runtime';
|
|
3
|
-
import {
|
|
4
|
-
import { Search as AlgoliaSearch, ZH_LOCALES, } from '@rspress/plugin-algolia/runtime';
|
|
3
|
+
import { Layout as OriginalLayout, getCustomMDXComponent, } from '@rspress/core/theme';
|
|
5
4
|
import virtual from 'doom-@global-virtual';
|
|
6
5
|
import { useMemo } from 'react';
|
|
7
6
|
import { useLocation } from 'react-router';
|
|
8
|
-
import classes from '
|
|
9
|
-
import { useTranslation } from
|
|
10
|
-
// eslint-disable-next-line import-x/export
|
|
11
|
-
export * from '@rspress/core/theme';
|
|
7
|
+
import classes from '../../styles/link.module.scss';
|
|
8
|
+
import { useTranslation } from "../runtime/index.js";
|
|
12
9
|
const X = getCustomMDXComponent();
|
|
13
10
|
const cleanupUrlPath = (urlPath) => {
|
|
14
11
|
if (urlPath.endsWith('.html')) {
|
|
@@ -58,7 +55,6 @@ const getClosestSidebar = (sidebarItems, pathname) => {
|
|
|
58
55
|
}
|
|
59
56
|
return found;
|
|
60
57
|
};
|
|
61
|
-
// eslint-disable-next-line import-x/export
|
|
62
58
|
export const Layout = () => {
|
|
63
59
|
const { site: { lang: siteLang, themeConfig }, } = useSite();
|
|
64
60
|
const lang = useLang();
|
|
@@ -87,20 +83,3 @@ export const Layout = () => {
|
|
|
87
83
|
withBase(`${found.exportItem.name ?? found.sidebar.text}-${lang}.pdf`), [found, lang]);
|
|
88
84
|
return (_jsx(OriginalLayout, { beforeOutline: pdfLink && (_jsx(X.p, { children: _jsx("a", { className: classes.link, href: pdfLink, target: "_blank", rel: "noopener noreferrer", children: t('view_docs_as_pdf') }) })) }));
|
|
89
85
|
};
|
|
90
|
-
// eslint-disable-next-line import-x/export
|
|
91
|
-
export const Search = process.env.ALGOLIA_APP_ID &&
|
|
92
|
-
process.env.ALGOLIA_API_KEY &&
|
|
93
|
-
process.env.ALGOLIA_INDEX_NAME
|
|
94
|
-
? () => {
|
|
95
|
-
const lang = useLang();
|
|
96
|
-
const docSearchProps = useMemo(() => ({
|
|
97
|
-
appId: process.env.ALGOLIA_APP_ID,
|
|
98
|
-
apiKey: process.env.ALGOLIA_API_KEY,
|
|
99
|
-
indexName: process.env.ALGOLIA_INDEX_NAME,
|
|
100
|
-
searchParameters: {
|
|
101
|
-
facetFilters: [`lang:${lang}`],
|
|
102
|
-
},
|
|
103
|
-
}), [lang]);
|
|
104
|
-
return (_jsx(AlgoliaSearch, { docSearchProps: docSearchProps, locales: ZH_LOCALES }));
|
|
105
|
-
}
|
|
106
|
-
: OriginalSearch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Search: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLang } from '@rspress/core/runtime';
|
|
3
|
+
import { Search as OriginalSearch } from '@rspress/core/theme';
|
|
4
|
+
import { Search as AlgoliaSearch, ZH_LOCALES, } from '@rspress/plugin-algolia/runtime';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
export const Search = process.env.ALGOLIA_APP_ID &&
|
|
7
|
+
process.env.ALGOLIA_API_KEY &&
|
|
8
|
+
process.env.ALGOLIA_INDEX_NAME
|
|
9
|
+
? () => {
|
|
10
|
+
const lang = useLang();
|
|
11
|
+
const docSearchProps = useMemo(() => ({
|
|
12
|
+
appId: process.env.ALGOLIA_APP_ID,
|
|
13
|
+
apiKey: process.env.ALGOLIA_API_KEY,
|
|
14
|
+
indexName: process.env.ALGOLIA_INDEX_NAME,
|
|
15
|
+
searchParameters: {
|
|
16
|
+
facetFilters: [`lang:${lang}`],
|
|
17
|
+
},
|
|
18
|
+
}), [lang]);
|
|
19
|
+
return (_jsx(AlgoliaSearch, { docSearchProps: docSearchProps, locales: ZH_LOCALES }));
|
|
20
|
+
}
|
|
21
|
+
: OriginalSearch;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useLocaleSiteData, usePageData } from '@rspress/runtime';
|
|
2
|
+
export function useEditLink() {
|
|
3
|
+
const { siteData, page } = usePageData();
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
5
|
+
const locales = useLocaleSiteData();
|
|
6
|
+
const editLink = locales.editLink ?? siteData.themeConfig.editLink;
|
|
7
|
+
if (!editLink?.docRepoBaseUrl || !editLink.text) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
let { docRepoBaseUrl } = editLink;
|
|
11
|
+
if (!docRepoBaseUrl.endsWith('/')) {
|
|
12
|
+
docRepoBaseUrl += '/';
|
|
13
|
+
}
|
|
14
|
+
const lastSegment = docRepoBaseUrl.split('/').at(-2);
|
|
15
|
+
const fixedLang = siteData.themeConfig.locales?.some(({ lang }) => lang === lastSegment);
|
|
16
|
+
const relativePagePath = page._relativePath.replace(/\\/g, '/');
|
|
17
|
+
const link = `${docRepoBaseUrl}${fixedLang ? relativePagePath.split('/').slice(1).join('/') : relativePagePath}`;
|
|
18
|
+
return {
|
|
19
|
+
text: editLink.text,
|
|
20
|
+
link,
|
|
21
|
+
};
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./eslint": "./lib/eslint.js",
|
|
22
22
|
"./runtime": "./lib/runtime/index.js",
|
|
23
23
|
"./styles/*": "./styles/*",
|
|
24
|
-
"./theme": "./lib/theme.js",
|
|
24
|
+
"./theme": "./lib/theme/index.js",
|
|
25
25
|
"./types": "./lib/types.js",
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
@@ -42,30 +42,30 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@alauda/doom-export": "^0.1.0",
|
|
44
44
|
"@cspell/eslint-plugin": "^8.19.4 || ^9.2.1",
|
|
45
|
-
"@eslint-react/eslint-plugin": "^1.53.
|
|
46
|
-
"@inquirer/prompts": "^7.8.
|
|
45
|
+
"@eslint-react/eslint-plugin": "^1.53.1",
|
|
46
|
+
"@inquirer/prompts": "^7.8.6",
|
|
47
47
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
48
48
|
"@playwright/browser-chromium": "^1.55.0",
|
|
49
49
|
"@rsbuild/plugin-react": "^1.4.0",
|
|
50
50
|
"@rsbuild/plugin-sass": "^1.4.0",
|
|
51
51
|
"@rsbuild/plugin-svgr": "^1.2.2",
|
|
52
52
|
"@rsbuild/plugin-yaml": "^1.0.3",
|
|
53
|
-
"@rspress/core": "2.0.0-beta.
|
|
54
|
-
"@rspress/plugin-algolia": "2.0.0-beta.
|
|
55
|
-
"@rspress/plugin-llms": "2.0.0-beta.
|
|
56
|
-
"@rspress/plugin-sitemap": "2.0.0-beta.
|
|
57
|
-
"@rspress/shared": "2.0.0-beta.
|
|
53
|
+
"@rspress/core": "2.0.0-beta.32",
|
|
54
|
+
"@rspress/plugin-algolia": "2.0.0-beta.32",
|
|
55
|
+
"@rspress/plugin-llms": "2.0.0-beta.32",
|
|
56
|
+
"@rspress/plugin-sitemap": "2.0.0-beta.32",
|
|
57
|
+
"@rspress/shared": "2.0.0-beta.32",
|
|
58
58
|
"@shikijs/transformers": "^3.12.2",
|
|
59
59
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
60
60
|
"ab64": "^0.1.6",
|
|
61
61
|
"chokidar": "^4.0.3",
|
|
62
62
|
"clsx": "^2.1.1",
|
|
63
|
-
"commander": "^13.1.0 || ^14.0.
|
|
63
|
+
"commander": "^13.1.0 || ^14.0.1",
|
|
64
64
|
"ejs": "^3.1.10",
|
|
65
65
|
"es-toolkit": "^1.39.10",
|
|
66
|
-
"eslint": "^9.
|
|
66
|
+
"eslint": "^9.35.0",
|
|
67
67
|
"eslint-plugin-mdx": "^3.6.2",
|
|
68
|
-
"globals": "^16.
|
|
68
|
+
"globals": "^16.4.0",
|
|
69
69
|
"html-tag-names": "^2.1.0",
|
|
70
70
|
"jsencrypt": "^3.5.4",
|
|
71
71
|
"md-attr-parser": "^1.3.0",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"mdast-util-phrasing": "^4.1.0",
|
|
75
75
|
"mdast-util-to-markdown": "^2.1.2",
|
|
76
76
|
"mdast-util-to-string": "^4.0.0",
|
|
77
|
-
"mermaid": "^11.
|
|
78
|
-
"openai": "^5.
|
|
77
|
+
"mermaid": "^11.11.0",
|
|
78
|
+
"openai": "^5.20.3",
|
|
79
79
|
"openapi-types": "^12.1.3",
|
|
80
80
|
"p-ratelimit": "^1.0.1",
|
|
81
81
|
"picomatch": "^4.0.3",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"simple-git": "^3.28.0",
|
|
101
101
|
"string-width": "^7.2.0",
|
|
102
102
|
"swagger2openapi": "^7.0.8",
|
|
103
|
-
"tinyglobby": "^0.2.
|
|
104
|
-
"type-fest": "^4.41.0",
|
|
103
|
+
"tinyglobby": "^0.2.15",
|
|
104
|
+
"type-fest": "^4.41.0 || ^5.0.0",
|
|
105
105
|
"typescript": "^5.9.2",
|
|
106
|
-
"typescript-eslint": "^8.
|
|
106
|
+
"typescript-eslint": "^8.44.0",
|
|
107
107
|
"unified": "^11.0.5",
|
|
108
108
|
"unified-lint-rule": "^3.0.1",
|
|
109
109
|
"unist-util-position": "^5.0.0",
|
package/lib/theme.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DoomSidebarGroup, DoomSidebarItem } from './plugins/index.js';
|
|
2
|
-
import type { ExportItem } from './types.js';
|
|
3
|
-
export * from '@rspress/core/theme';
|
|
4
|
-
export interface MatchedSidebar {
|
|
5
|
-
sidebar: DoomSidebarGroup | DoomSidebarItem;
|
|
6
|
-
exportItem: ExportItem;
|
|
7
|
-
depth: number;
|
|
8
|
-
}
|
|
9
|
-
export declare const Layout: () => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare const Search: () => import("react/jsx-runtime").JSX.Element;
|