@alauda/doom 1.9.0 → 1.9.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/cli/export.js +2 -2
- package/lib/cli/index.js +8 -6
- package/lib/cli/load-config.d.ts +1 -1
- package/lib/cli/load-config.js +6 -4
- package/lib/global/VersionsNav/NavMenuGroup.js +2 -1
- package/lib/global/VersionsNav/NavMenuSingleItem.js +2 -1
- package/lib/global/VersionsNav/index.js +6 -5
- package/lib/runtime/components/Overview.js +10 -12
- package/lib/runtime/components/_utils.d.ts +5 -1
- package/lib/runtime/components/_utils.js +7 -9
- package/lib/runtime/hooks/useSiteOverrides.js +5 -6
- package/lib/shared/helpers.d.ts +3 -0
- package/lib/shared/helpers.js +3 -0
- package/package.json +4 -4
package/lib/cli/export.js
CHANGED
|
@@ -38,7 +38,7 @@ export const exportCommand = new Command('export')
|
|
|
38
38
|
.action(async function (root) {
|
|
39
39
|
setNodeEnv('production');
|
|
40
40
|
const { port, host, ...globalOptions } = this.optsWithGlobals();
|
|
41
|
-
let { config } = await loadConfig(root, {
|
|
41
|
+
let { config, configFilePath } = await loadConfig(root, {
|
|
42
42
|
...globalOptions,
|
|
43
43
|
export: true,
|
|
44
44
|
});
|
|
@@ -55,7 +55,7 @@ export const exportCommand = new Command('export')
|
|
|
55
55
|
// make sure it won't be overridden by `serve`
|
|
56
56
|
const themeConfig = { ...config.themeConfig };
|
|
57
57
|
logger.start('Serving...');
|
|
58
|
-
await serve({ config, host, port });
|
|
58
|
+
await serve({ config, configFilePath, host, port });
|
|
59
59
|
const tempDir = path.resolve(outDir, '.doom');
|
|
60
60
|
const commonOptions = {
|
|
61
61
|
tempDir,
|
package/lib/cli/index.js
CHANGED
|
@@ -59,11 +59,12 @@ program
|
|
|
59
59
|
let cliWatcher;
|
|
60
60
|
const { port, host, ...globalOptions } = this.optsWithGlobals();
|
|
61
61
|
const startDevServer = async () => {
|
|
62
|
-
const { config,
|
|
62
|
+
const { config, configFilePath } = await loadConfig(root, globalOptions);
|
|
63
63
|
const docDirectory = config.root;
|
|
64
64
|
try {
|
|
65
65
|
devServer = await dev({
|
|
66
66
|
config,
|
|
67
|
+
configFilePath,
|
|
67
68
|
appDirectory: CWD,
|
|
68
69
|
docDirectory,
|
|
69
70
|
extraBuilderConfig: {
|
|
@@ -75,8 +76,8 @@ program
|
|
|
75
76
|
logger.error(err);
|
|
76
77
|
devServer = undefined;
|
|
77
78
|
}
|
|
78
|
-
cliWatcher = watch(
|
|
79
|
-
? [
|
|
79
|
+
cliWatcher = watch(configFilePath
|
|
80
|
+
? [configFilePath, config.i18nSourcePath, docDirectory, SITES_FILE]
|
|
80
81
|
: [...CONFIG_FILES, docDirectory], {
|
|
81
82
|
ignoreInitial: true,
|
|
82
83
|
ignored: ['**/node_modules/**', '**/.git/**', '**/.DS_Store/**'],
|
|
@@ -121,10 +122,11 @@ program
|
|
|
121
122
|
.argument('[root]', 'Root directory of the documentation')
|
|
122
123
|
.action(async function (root) {
|
|
123
124
|
setNodeEnv('production');
|
|
124
|
-
const { config } = await loadConfig(root, this.optsWithGlobals());
|
|
125
|
+
const { config, configFilePath } = await loadConfig(root, this.optsWithGlobals());
|
|
125
126
|
const docDirectory = config.root;
|
|
126
127
|
const runBuild = () => build({
|
|
127
128
|
config,
|
|
129
|
+
configFilePath,
|
|
128
130
|
docDirectory,
|
|
129
131
|
});
|
|
130
132
|
await runBuild();
|
|
@@ -143,8 +145,8 @@ program
|
|
|
143
145
|
.action(async function (root) {
|
|
144
146
|
setNodeEnv('production');
|
|
145
147
|
const { port, host, ...globalOptions } = this.optsWithGlobals();
|
|
146
|
-
const { config } = await loadConfig(root, globalOptions);
|
|
147
|
-
await serve({ config, host, port });
|
|
148
|
+
const { config, configFilePath } = await loadConfig(root, globalOptions);
|
|
149
|
+
await serve({ config, configFilePath, host, port });
|
|
148
150
|
});
|
|
149
151
|
program.addCommand(newCommand);
|
|
150
152
|
program.addCommand(translateCommand);
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { type UserConfig } from '@rspress/core';
|
|
|
2
2
|
import type { GlobalCliOptions } from '../types.js';
|
|
3
3
|
export declare function loadConfig(root?: string | URL, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
|
-
|
|
5
|
+
configFilePath: string;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function resolveDocRoot(cliRoot?: string, configRoot?: string): string;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -216,6 +216,11 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
216
216
|
server: {
|
|
217
217
|
open,
|
|
218
218
|
},
|
|
219
|
+
performance: {
|
|
220
|
+
buildCache: {
|
|
221
|
+
cacheDigest: [root, configFilePath, base, version],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
219
224
|
tools: {
|
|
220
225
|
rspack(rspackConfig, { mergeConfig, rspack }) {
|
|
221
226
|
return mergeConfig(rspackConfig, {
|
|
@@ -361,12 +366,9 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
361
366
|
outDir ||= mergedConfig.outDir;
|
|
362
367
|
mergedConfig.outDir = `dist${(outDir ? addLeadingSlash(addTrailingSlash(outDir)) : base) +
|
|
363
368
|
(isExplicitlyUnversioned(version) ? UNVERSIONED : outDir ? version : '')}`;
|
|
364
|
-
if (mergedConfig.builderConfig?.server?.open === true) {
|
|
365
|
-
mergedConfig.builderConfig.server.open = mergedConfig.base;
|
|
366
|
-
}
|
|
367
369
|
return {
|
|
368
370
|
config: mergedConfig,
|
|
369
|
-
|
|
371
|
+
configFilePath: configFilePath || '',
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
374
|
export function resolveDocRoot(cliRoot, configRoot) {
|
|
@@ -1,7 +1,8 @@
|
|
|
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 { isExternalUrl,
|
|
3
|
+
import { isExternalUrl, } from '@rspress/shared';
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
5
|
+
import { matchNavbar } from '../../shared/index.js';
|
|
5
6
|
import { Down } from './Down.js';
|
|
6
7
|
import { NavMenuSingleItem, } from './NavMenuSingleItem.js';
|
|
7
8
|
import { SvgWrapper } from './SvgWrapper.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Tag } from '@rspress/core/theme';
|
|
3
|
-
import { isExternalUrl
|
|
3
|
+
import { isExternalUrl } from '@rspress/shared';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import styles from '../../../styles/versions-nav.module.scss';
|
|
6
|
+
import { withoutBase } from '../../shared/index.js';
|
|
6
7
|
export function NavMenuSingleItem({ activeMatch, base, compact, download, link, pathname, rightIcon, text, tag, }) {
|
|
7
8
|
const isActive = useMemo(() => !!base &&
|
|
8
9
|
!!pathname &&
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isProduction, NoSSR,
|
|
2
|
+
import { isProduction, NoSSR, usePageData, withBase, } from '@rspress/core/runtime';
|
|
3
3
|
import {} from '@rspress/shared';
|
|
4
4
|
import virtual from 'doom-@global-virtual';
|
|
5
5
|
import { noop } from 'es-toolkit';
|
|
6
6
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
|
+
import { base } from 'virtual-runtime-config';
|
|
8
9
|
import { parse } from 'yaml';
|
|
9
10
|
import { ACP_BASE, getPdfName, getUnversionedVersion, isExplicitlyUnversioned, } from '../../shared/index.js';
|
|
10
11
|
import { NavMenuGroup } from './NavMenuGroup.js';
|
|
@@ -44,10 +45,10 @@ const VersionsNav_ = () => {
|
|
|
44
45
|
return [
|
|
45
46
|
isExplicitlyUnversioned(virtual.version)
|
|
46
47
|
? undefined
|
|
47
|
-
:
|
|
48
|
+
: base.slice(0, -unversionedVersion.length - 1),
|
|
48
49
|
unversionedVersion,
|
|
49
50
|
];
|
|
50
|
-
}, [
|
|
51
|
+
}, []);
|
|
51
52
|
const [navMenu, setNavMenu] = useState(getNavMenu);
|
|
52
53
|
const [versions, setVersions] = useState(version ? [version] : []);
|
|
53
54
|
useEffect(() => {
|
|
@@ -58,7 +59,7 @@ const VersionsNav_ = () => {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
const res = await fetch(`${isProduction() ? versionsBase :
|
|
62
|
+
const res = await fetch(`${isProduction() ? versionsBase : base}/versions.yaml`);
|
|
62
63
|
if (!res.ok) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -111,7 +112,7 @@ const VersionsNav_ = () => {
|
|
|
111
112
|
!(finalNavMenu = getNavMenu())) {
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
|
-
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:
|
|
115
|
+
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: base }))] }), finalNavMenu);
|
|
115
116
|
};
|
|
116
117
|
export const VersionsNav = () => (_jsx(NoSSR, { children: _jsx(VersionsNav_, {}) }));
|
|
117
118
|
export default VersionsNav;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Link, renderInlineMarkdown, useSidebarData } from '@rspress/core/theme';
|
|
3
|
-
import { isEqualPath, normalizeHrefInRuntime as normalizeHref, usePageData,
|
|
3
|
+
import { isEqualPath, normalizeHrefInRuntime as normalizeHref, usePageData, } from '@rspress/runtime';
|
|
4
4
|
import { Fragment, useCallback, useMemo } from 'react';
|
|
5
5
|
import classes from '../../../styles/overview.module.scss';
|
|
6
|
-
import { findItemByRoutePath } from './_utils.js';
|
|
6
|
+
import { findItemByRoutePath, isSidebarDivider, isSidebarSectionHeader, isSingleFile, } from './_utils.js';
|
|
7
7
|
const getChildLink = (traverseItem) => {
|
|
8
8
|
if ('link' in traverseItem && traverseItem.link) {
|
|
9
9
|
return traverseItem.link;
|
|
@@ -22,8 +22,8 @@ export function Overview(props) {
|
|
|
22
22
|
const subFilter = useCallback((link) =>
|
|
23
23
|
// sidebar items link without base path
|
|
24
24
|
// pages route path with base path
|
|
25
|
-
|
|
26
|
-
!isEqualPath(
|
|
25
|
+
link.startsWith(routePath.replace(/overview$/, '')) &&
|
|
26
|
+
!isEqualPath(link, routePath), [routePath]);
|
|
27
27
|
const { pages } = siteData;
|
|
28
28
|
const overviewModules = useMemo(() => pages.filter((page) => subFilter(page.routePath)), [pages, subFilter]);
|
|
29
29
|
let overviewSidebarGroups = useSidebarData();
|
|
@@ -33,12 +33,11 @@ export function Overview(props) {
|
|
|
33
33
|
overviewSidebarGroups = findItemByRoutePath(overviewSidebarGroups, routePath);
|
|
34
34
|
}
|
|
35
35
|
const normalizeSidebarItem = useCallback((item, sidebarGroup, frontmatter) => {
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
36
|
+
if (isSidebarDivider(item) || isSidebarSectionHeader(item)) {
|
|
37
|
+
return false;
|
|
38
38
|
}
|
|
39
39
|
// do not display overview title in sub pages overview
|
|
40
|
-
if (
|
|
41
|
-
frontmatter?.overview === true) {
|
|
40
|
+
if (item.link === `${routePath}index` && frontmatter?.overview === true) {
|
|
42
41
|
return false;
|
|
43
42
|
}
|
|
44
43
|
// props > frontmatter in single file > _meta.json config in a file > frontmatter in overview page > _meta.json config in sidebar
|
|
@@ -47,7 +46,7 @@ export function Overview(props) {
|
|
|
47
46
|
frontmatter?.overviewHeaders ??
|
|
48
47
|
sidebarGroup?.overviewHeaders ?? [2];
|
|
49
48
|
// sidebar items link without base path
|
|
50
|
-
const pageModule = overviewModules.find((m) => isEqualPath(m.routePath,
|
|
49
|
+
const pageModule = overviewModules.find((m) => isEqualPath(m.routePath, item.link || ''));
|
|
51
50
|
const link = getChildLink(item);
|
|
52
51
|
return {
|
|
53
52
|
...item,
|
|
@@ -56,7 +55,6 @@ export function Overview(props) {
|
|
|
56
55
|
headers: pageModule?.toc.filter((header) => overviewHeaders.some((depth) => header.depth === depth)) || [],
|
|
57
56
|
};
|
|
58
57
|
}, [overviewModules, props.overviewHeaders, routePath]);
|
|
59
|
-
const isSingleFile = (item) => !('items' in item) && 'link' in item;
|
|
60
58
|
const getGroup = useCallback((sidebarGroups) => {
|
|
61
59
|
const group = sidebarGroups
|
|
62
60
|
.filter((sidebarGroup) => {
|
|
@@ -75,7 +73,7 @@ export function Overview(props) {
|
|
|
75
73
|
if ('items' in sidebarGroup) {
|
|
76
74
|
items = sidebarGroup.items
|
|
77
75
|
.map((item) => normalizeSidebarItem(item, sidebarGroup, frontmatter))
|
|
78
|
-
.filter(
|
|
76
|
+
.filter(Boolean);
|
|
79
77
|
}
|
|
80
78
|
else if (isSingleFile(sidebarGroup)) {
|
|
81
79
|
items = [
|
|
@@ -86,7 +84,7 @@ export function Overview(props) {
|
|
|
86
84
|
_fileKey: sidebarGroup._fileKey,
|
|
87
85
|
overviewHeaders: sidebarGroup.overviewHeaders,
|
|
88
86
|
}, undefined, frontmatter),
|
|
89
|
-
].filter(
|
|
87
|
+
].filter(Boolean);
|
|
90
88
|
}
|
|
91
89
|
return {
|
|
92
90
|
name: ('text' in sidebarGroup && sidebarGroup.text) || '',
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { NormalizedSidebarGroup, SidebarDivider, SidebarItem, SidebarSectionHeader } from '@rspress/shared';
|
|
2
2
|
export declare const isSidebarDivider: (item: NormalizedSidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader) => item is SidebarDivider;
|
|
3
|
+
export declare const isSidebarSectionHeader: (item: NormalizedSidebarGroup | SidebarItem | SidebarDivider | SidebarSectionHeader) => item is SidebarSectionHeader;
|
|
4
|
+
export declare const isSingleFile: (item: SidebarItem | SidebarSectionHeader | SidebarDivider | NormalizedSidebarGroup) => item is SidebarItem | (NormalizedSidebarGroup & {
|
|
5
|
+
link: string;
|
|
6
|
+
});
|
|
3
7
|
/**
|
|
4
8
|
* @zh_CN 如果 index 在 sidebar items 中, 则返回所有平级 item, 如果 index 在 dir 上, 则返回 items
|
|
5
9
|
* @example
|
|
6
10
|
*/
|
|
7
|
-
export declare function findItemByRoutePath(items: (SidebarItem | NormalizedSidebarGroup | SidebarDivider)[], routePath: string): (SidebarItem | NormalizedSidebarGroup)[];
|
|
11
|
+
export declare function findItemByRoutePath(items: (SidebarItem | SidebarSectionHeader | NormalizedSidebarGroup | SidebarDivider)[], routePath: string): (SidebarItem | NormalizedSidebarGroup)[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { withBase } from '@rspress/core/runtime';
|
|
2
1
|
function removeIndex(link) {
|
|
3
2
|
if (link.endsWith('/index')) {
|
|
4
3
|
return link.slice(0, -5);
|
|
@@ -8,23 +7,22 @@ function removeIndex(link) {
|
|
|
8
7
|
export const isSidebarDivider = (item) => {
|
|
9
8
|
return 'dividerType' in item;
|
|
10
9
|
};
|
|
10
|
+
export const isSidebarSectionHeader = (item) => {
|
|
11
|
+
return 'sectionHeaderText' in item;
|
|
12
|
+
};
|
|
13
|
+
export const isSingleFile = (item) => !('items' in item) && 'link' in item;
|
|
11
14
|
/**
|
|
12
15
|
* @zh_CN 如果 index 在 sidebar items 中, 则返回所有平级 item, 如果 index 在 dir 上, 则返回 items
|
|
13
16
|
* @example
|
|
14
17
|
*/
|
|
15
18
|
export function findItemByRoutePath(items, routePath) {
|
|
16
19
|
function isRoutePathMatch(item) {
|
|
17
|
-
if (isSidebarDivider(item)) {
|
|
20
|
+
if (isSidebarDivider(item) || isSidebarSectionHeader(item)) {
|
|
18
21
|
return false;
|
|
19
22
|
}
|
|
20
|
-
const
|
|
21
|
-
const removeIndexUrl = removeIndex(withBaseUrl);
|
|
23
|
+
const removeIndexUrl = removeIndex(item.link || '/');
|
|
22
24
|
const removeBackSlashedRoutePath = routePath.replace(/\/$/, '');
|
|
23
|
-
return (
|
|
24
|
-
// FIXME: 😅 we should refactor all the path logic, /index.html / or no /, l
|
|
25
|
-
withBaseUrl === routePath ||
|
|
26
|
-
removeIndexUrl === routePath ||
|
|
27
|
-
withBaseUrl === removeBackSlashedRoutePath ||
|
|
25
|
+
return (removeIndexUrl === routePath ||
|
|
28
26
|
removeIndexUrl === removeBackSlashedRoutePath);
|
|
29
27
|
}
|
|
30
28
|
const matchRoutePathItemIndex = items.findIndex((item) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProduction,
|
|
1
|
+
import { isProduction, withBase } from '@rspress/core/runtime';
|
|
2
2
|
import virtual from 'doom-@global-virtual';
|
|
3
3
|
import { merge } from 'es-toolkit/compat';
|
|
4
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
@@ -19,14 +19,14 @@ const normalizeOverrides = (origin) => Object.keys(origin).reduce((acc, key_) =>
|
|
|
19
19
|
}, { en: {}, zh: {}, ru: {} });
|
|
20
20
|
let normalizedSiteOverrides;
|
|
21
21
|
let promise;
|
|
22
|
-
const fetchSiteOverrides = async (
|
|
22
|
+
const fetchSiteOverrides = async (version, acpSite) => {
|
|
23
23
|
if (promise) {
|
|
24
24
|
return promise;
|
|
25
25
|
}
|
|
26
26
|
const acpSiteOverridesUrl = acpSite && isProduction()
|
|
27
27
|
? `${(virtual.prefix || '') + acpSite.base}${isUnversioned(version) ? '' : acpSite.version + '/'}overrides.yaml`
|
|
28
28
|
: null;
|
|
29
|
-
const siteOverridesUrl =
|
|
29
|
+
const siteOverridesUrl = withBase('overrides.yaml');
|
|
30
30
|
const urls = [acpSiteOverridesUrl];
|
|
31
31
|
if (acpSiteOverridesUrl !== siteOverridesUrl) {
|
|
32
32
|
urls.push(siteOverridesUrl);
|
|
@@ -62,7 +62,6 @@ const fetchSiteOverrides = async (base, version, acpSite) => {
|
|
|
62
62
|
}));
|
|
63
63
|
};
|
|
64
64
|
export const useSiteOverrides = () => {
|
|
65
|
-
const { siteData } = usePageData();
|
|
66
65
|
const [siteOverrides, setSiteOverrides] = useState(normalizedSiteOverrides);
|
|
67
66
|
const lang = useLang();
|
|
68
67
|
const acpSite = useMemo(() => virtual.sites?.find((s) => s.name === 'acp'), []);
|
|
@@ -70,7 +69,7 @@ export const useSiteOverrides = () => {
|
|
|
70
69
|
if (normalizedSiteOverrides) {
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
|
-
void fetchSiteOverrides(
|
|
74
|
-
}, [acpSite
|
|
72
|
+
void fetchSiteOverrides(virtual.version, acpSite).then(setSiteOverrides);
|
|
73
|
+
}, [acpSite]);
|
|
75
74
|
return siteOverrides?.[lang] || {};
|
|
76
75
|
};
|
package/lib/shared/helpers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NavItemWithLink } from '@rspress/shared';
|
|
1
2
|
import type { UnversionedVersion } from './types.ts';
|
|
2
3
|
export declare const removeBothEndsSlashes: (str?: string) => string;
|
|
3
4
|
export declare const getPdfName: (lang: string, userBase?: string, title?: string) => string;
|
|
@@ -8,3 +9,5 @@ export declare const getUnversionedVersion: (version?: string) => string | undef
|
|
|
8
9
|
* hello world {#custom-id} -> { text: 'hello world', id: 'custom-id' }
|
|
9
10
|
*/
|
|
10
11
|
export declare const extractTextAndId: (title: string) => string[];
|
|
12
|
+
export declare const withoutBase: (path: string, base: string) => string;
|
|
13
|
+
export declare const matchNavbar: (item: NavItemWithLink, currentPathname: string, base: string) => boolean;
|
package/lib/shared/helpers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addLeadingSlash, normalizeSlash, } from '@rspress/shared';
|
|
1
2
|
import { UNVERSIONED, UNVERSIONED_PREFIX } from "./constants.js";
|
|
2
3
|
export const removeBothEndsSlashes = (str) => str?.replace(/^\/|\/$/g, '') || '';
|
|
3
4
|
export const getPdfName = (lang, userBase, title) => `${removeBothEndsSlashes(userBase) || title || 'exported'}-${lang}.pdf`;
|
|
@@ -23,3 +24,5 @@ export const extractTextAndId = (title) => {
|
|
|
23
24
|
customId,
|
|
24
25
|
];
|
|
25
26
|
};
|
|
27
|
+
export const withoutBase = (path, base) => addLeadingSlash(path).replace(normalizeSlash(base), '');
|
|
28
|
+
export const matchNavbar = (item, currentPathname, base) => new RegExp(item.activeMatch || item.link).test(withoutBase(currentPathname, base));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"@rsbuild/plugin-sass": "^1.3.3",
|
|
46
46
|
"@rsbuild/plugin-svgr": "^1.2.1",
|
|
47
47
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
48
|
-
"@rspress/core": "2.0.0-beta.
|
|
49
|
-
"@rspress/plugin-algolia": "2.0.0-beta.
|
|
50
|
-
"@rspress/plugin-llms": "2.0.0-beta.
|
|
48
|
+
"@rspress/core": "2.0.0-beta.20",
|
|
49
|
+
"@rspress/plugin-algolia": "2.0.0-beta.20",
|
|
50
|
+
"@rspress/plugin-llms": "2.0.0-beta.20",
|
|
51
51
|
"@shikijs/transformers": "^3.7.0",
|
|
52
52
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
53
53
|
"chokidar": "^4.0.3",
|