@alauda/doom 1.7.0 → 1.8.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { NoSSR, useLang } from '@rspress/core/runtime';
|
|
2
|
+
import { NoSSR, useLang, usePageData } from '@rspress/core/runtime';
|
|
3
3
|
import { addTrailingSlash, isExternalUrl, normalizeHref, parseUrl, removeLeadingSlash, } from '@rspress/shared';
|
|
4
4
|
import { DEFAULT_PAGE_EXTENSIONS } from '@rspress/shared/constants';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -11,6 +11,7 @@ import { useIsPrint } from '../hooks/index.js';
|
|
|
11
11
|
import { Directive } from './Directive.js';
|
|
12
12
|
const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
13
13
|
const isPrint = useIsPrint();
|
|
14
|
+
const { siteData } = usePageData();
|
|
14
15
|
const site = useMemo(() => virtual.sites?.find((s) => s.name === name), [name]);
|
|
15
16
|
const lang = useLang();
|
|
16
17
|
if (!site) {
|
|
@@ -20,7 +21,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
|
20
21
|
return _jsxs(Directive, { type: "danger", children: ["Invalid href `", href, "` found"] });
|
|
21
22
|
}
|
|
22
23
|
let { url, hash } = parseUrl(href);
|
|
23
|
-
const extname = url.split('.').
|
|
24
|
+
const extname = url.split('.').at(-1);
|
|
24
25
|
if (extname) {
|
|
25
26
|
if (DEFAULT_PAGE_EXTENSIONS.includes(`.${extname}`)) {
|
|
26
27
|
url = url.replace(new RegExp(`\\.${extname}$`), '');
|
|
@@ -32,7 +33,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
|
|
|
32
33
|
(isUnversioned(virtual.version)
|
|
33
34
|
? site.base
|
|
34
35
|
: addTrailingSlash(site.base + site.version)) +
|
|
35
|
-
(lang ? addTrailingSlash(lang) : '') +
|
|
36
|
+
(lang && lang !== siteData.lang ? addTrailingSlash(lang) : '') +
|
|
36
37
|
(hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'rp-cursor-pointer', className), ...props }));
|
|
37
38
|
};
|
|
38
39
|
export const ExternalSiteLink = (props) => (_jsx(NoSSR, { children: _jsx(ExternalSiteLink_, { ...props }) }));
|
package/lib/theme.js
CHANGED
|
@@ -13,6 +13,9 @@ const X = getCustomMDXComponent();
|
|
|
13
13
|
const getClosestSidebar_ = (sidebarItems, pathname, exportItem, matched, depth = 0) => {
|
|
14
14
|
for (const sidebar of sidebarItems) {
|
|
15
15
|
if ('_fileKey' in sidebar && sidebar._fileKey) {
|
|
16
|
+
if (depth === 0) {
|
|
17
|
+
matched = undefined;
|
|
18
|
+
}
|
|
16
19
|
if (exportItem.entry.includes(sidebar._fileKey)) {
|
|
17
20
|
matched = {
|
|
18
21
|
sidebar,
|
|
@@ -26,7 +29,7 @@ const getClosestSidebar_ = (sidebarItems, pathname, exportItem, matched, depth =
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
if ('items' in sidebar) {
|
|
29
|
-
const found = getClosestSidebar_(sidebar.items, pathname, exportItem, matched);
|
|
32
|
+
const found = getClosestSidebar_(sidebar.items, pathname, exportItem, matched, depth + 1);
|
|
30
33
|
if (found) {
|
|
31
34
|
return found;
|
|
32
35
|
}
|
|
@@ -56,9 +59,13 @@ export const Layout = () => {
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
if (themeConfig.locales?.length) {
|
|
62
|
+
let found;
|
|
59
63
|
for (const { lang, sidebar } of themeConfig.locales) {
|
|
60
64
|
const sidebarItems = sidebar[siteLang === lang ? '/' : `/${lang}`];
|
|
61
|
-
|
|
65
|
+
found ??= getClosestSidebar(sidebarItems, pathname);
|
|
66
|
+
if (found) {
|
|
67
|
+
return found;
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
else {
|
package/package.json
CHANGED
package/styles/global.scss
CHANGED
|
@@ -54,7 +54,7 @@ td {
|
|
|
54
54
|
margin-left: 4px;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.has-callouts
|
|
57
|
+
.has-callouts {
|
|
58
58
|
counter-reset: callouts;
|
|
59
59
|
|
|
60
60
|
.line.callout {
|
|
@@ -145,3 +145,14 @@ td {
|
|
|
145
145
|
@media print {
|
|
146
146
|
@include print;
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
.rp-list-decimal {
|
|
150
|
+
list-style: none;
|
|
151
|
+
counter-reset: section;
|
|
152
|
+
padding-left: 20px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.rp-list-decimal > li:before {
|
|
156
|
+
counter-increment: section;
|
|
157
|
+
content: counters(section, '.') '. ';
|
|
158
|
+
}
|