@rspress/core 2.0.3 → 2.0.4
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/dist/{0~7675.872de9ba.js → 0~7675.423f6a06.js} +2 -2
- package/dist/{5485.888e77db.js → 5485.7e481fde.js} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Badge/index.tsx +1 -1
- package/dist/eject-theme/components/Button/index.tsx +1 -1
- package/dist/eject-theme/components/CodeBlock/index.scss +5 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +7 -2
- package/dist/eject-theme/components/EditLink/index.scss +10 -8
- package/dist/eject-theme/components/EditLink/index.tsx +13 -4
- package/dist/eject-theme/components/HoverGroup/index.tsx +8 -2
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +51 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.scss +10 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +170 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +7 -1
- package/dist/eject-theme/components/Nav/hooks.tsx +2 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +8 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +0 -1
- package/dist/eject-theme/components/Outline/ScrollToTop.tsx +12 -34
- package/dist/eject-theme/components/Outline/index.scss +41 -5
- package/dist/eject-theme/components/Outline/index.tsx +19 -2
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +10 -2
- package/dist/eject-theme/components/Search/SearchPanel.tsx +2 -1
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -2
- package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
- package/dist/eject-theme/components/SvgWrapper/index.tsx +5 -2
- package/dist/eject-theme/components/Tabs/index.scss +1 -1
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/index.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +30 -4
- package/dist/node/constants.js +1 -1
- package/dist/node/initRsbuild.js +11 -9
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.d.ts +0 -3
- package/dist/node/logger/hint.js +7 -1
- package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +3 -2
- package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +4 -3
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +23 -2
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +4 -4
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +4 -4
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +11 -1
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/reactAlias.d.ts +1 -0
- package/dist/node/utils/reactAlias.js +34 -2
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/theme/assets/copy.js +3 -3
- package/dist/theme/assets/edit.js +18 -0
- package/dist/theme/assets/scroll-to-top.js +36 -0
- package/dist/theme/assets/success.js +3 -2
- package/dist/theme/components/Badge/index.d.ts +1 -2
- package/dist/theme/components/Button/index.d.ts +1 -2
- package/dist/theme/components/CodeBlock/index.css +5 -1
- package/dist/theme/components/DocContent/docComponents/title.js +5 -2
- package/dist/theme/components/EditLink/index.css +2 -2
- package/dist/theme/components/EditLink/index.d.ts +3 -1
- package/dist/theme/components/EditLink/index.js +18 -4
- package/dist/theme/components/HoverGroup/index.js +8 -1
- package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsCopyRow.js +50 -0
- package/dist/theme/components/Llms/LlmsOpenRow.css +11 -0
- package/dist/theme/components/Llms/LlmsOpenRow.d.ts +3 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +168 -0
- package/dist/theme/components/Nav/NavMenu.js +3 -0
- package/dist/theme/components/Nav/hooks.d.ts +2 -0
- package/dist/theme/components/Nav/hooks.js +3 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.js +3 -0
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +0 -1
- package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -2
- package/dist/theme/components/Outline/ScrollToTop.js +7 -32
- package/dist/theme/components/Outline/index.css +39 -4
- package/dist/theme/components/Outline/index.js +16 -4
- package/dist/theme/components/PackageManagerTabs/index.js +10 -3
- package/dist/theme/components/Search/SearchPanel.js +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -2
- package/dist/theme/components/SourceCode/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.js +2 -1
- package/dist/theme/components/Tabs/index.css +1 -1
- package/dist/theme/components/Tabs/index.d.ts +1 -1
- package/dist/theme/icons.d.ts +2 -0
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +8 -5
- package/dist/theme/index.js +4 -1
- package/dist/theme/layout/DocLayout/index.css +3 -3
- package/dist/theme/styles/base.css +4 -0
- package/nav-json-schema.json +12 -0
- package/package.json +14 -16
- package/dist/_private/react/index.js +0 -2
- package/dist/_private/react/reconciler.js +0 -169
- package/dist/_private/react/render.js +0 -168
- package/dist/eject-theme/components/Outline/ScrollToTop.scss +0 -13
- package/dist/node/ssg-md/react/index.d.ts +0 -1
- package/dist/node/ssg-md/react/reconciler.d.ts +0 -18
- package/dist/node/ssg-md/react/render.d.ts +0 -2
- package/dist/node/ssg-md/react/render.test.d.ts +0 -1
- package/dist/theme/components/Outline/ScrollToTop.css +0 -14
- /package/dist/{8995.421b464f.js → 7744.421b464f.js} +0 -0
|
@@ -9,8 +9,8 @@ import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
10
|
import { node_process, node_os, constants } from "./9348.1beb3e25.js";
|
|
11
11
|
import { node_path } from "./6289.29817fb4.js";
|
|
12
|
-
import { node_url } from "./5485.
|
|
13
|
-
import { createWriteStream, createReadStream, readFileSync } from "./
|
|
12
|
+
import { node_url } from "./5485.7e481fde.js";
|
|
13
|
+
import { createWriteStream, createReadStream, readFileSync } from "./7744.421b464f.js";
|
|
14
14
|
__webpack_require__.add({
|
|
15
15
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
16
16
|
const cp = __webpack_require__("child_process");
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { node_path, logger, join, picocolors } from "../6289.29817fb4.js";
|
|
2
2
|
import { chokidar, cac } from "./index.44f3184c.js";
|
|
3
|
-
import { package_namespaceObject } from "../5485.
|
|
3
|
+
import { package_namespaceObject } from "../5485.7e481fde.js";
|
|
4
4
|
import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
|
|
5
5
|
import { dev } from "../node/dev.js";
|
|
6
6
|
import { PUBLIC_DIR } from "../node/constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../
|
|
1
|
+
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../7744.421b464f.js";
|
|
2
2
|
import { node_path, logger } from "../6289.29817fb4.js";
|
|
3
3
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
4
4
|
async function loadConfigFile(customConfigFile) {
|
|
@@ -74,13 +74,17 @@
|
|
|
74
74
|
counter-reset: step;
|
|
75
75
|
counter-increment: step 0;
|
|
76
76
|
& .line::before {
|
|
77
|
+
width: 2ch;
|
|
77
78
|
content: counter(step);
|
|
78
79
|
counter-increment: step;
|
|
79
|
-
width: 1rem;
|
|
80
80
|
margin-right: 1rem;
|
|
81
81
|
display: inline-block;
|
|
82
82
|
text-align: right;
|
|
83
83
|
color: rgba(115, 138, 148, 0.4);
|
|
84
84
|
}
|
|
85
|
+
// 100+ for 3 digits
|
|
86
|
+
&:has(.line:nth-child(100)) .line::before {
|
|
87
|
+
width: 3ch;
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useFrontmatter } from '@rspress/core/runtime';
|
|
1
|
+
import { useFrontmatter, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, Tag } from '@theme';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import type React from 'react';
|
|
@@ -10,12 +10,17 @@ export const H1 = (props: React.ComponentProps<'h1'>) => {
|
|
|
10
10
|
frontmatter: { tag },
|
|
11
11
|
} = useFrontmatter();
|
|
12
12
|
|
|
13
|
+
const { site } = useSite();
|
|
14
|
+
const llmsUI = site?.themeConfig?.llmsUI;
|
|
15
|
+
const placement =
|
|
16
|
+
typeof llmsUI === 'object' ? (llmsUI?.placement ?? 'title') : 'title';
|
|
17
|
+
|
|
13
18
|
return (
|
|
14
19
|
<>
|
|
15
20
|
<h1 className={clsx('rp-toc-include', className)} {...rest}>
|
|
16
21
|
{children} <Tag tag={tag} />
|
|
17
22
|
</h1>
|
|
18
|
-
{process.env.ENABLE_LLMS_UI && (
|
|
23
|
+
{process.env.ENABLE_LLMS_UI && placement === 'title' && (
|
|
19
24
|
<LlmsContainer>
|
|
20
25
|
<LlmsCopyButton />
|
|
21
26
|
<LlmsViewOptions />
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
.rp-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
.rp-doc-footer {
|
|
2
|
+
.rp-edit-link {
|
|
3
|
+
color: var(--rp-c-brand);
|
|
4
|
+
text-decoration: none;
|
|
5
|
+
font-size: 15px;
|
|
6
|
+
font-weight: 500;
|
|
7
|
+
transition: all 0.2s ease-in-out;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
&:hover {
|
|
10
|
+
color: var(--rp-c-brand-dark);
|
|
11
|
+
}
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IconEdit, Link, SvgWrapper } from '@theme';
|
|
1
2
|
import './index.scss';
|
|
2
3
|
import { useEditLink } from './useEditLink';
|
|
3
4
|
|
|
4
|
-
export function EditLink() {
|
|
5
|
+
export function EditLink({ isOutline }: { isOutline?: boolean }) {
|
|
5
6
|
const editLinkObj = useEditLink();
|
|
6
7
|
|
|
7
8
|
if (!editLinkObj) {
|
|
@@ -10,10 +11,18 @@ export function EditLink() {
|
|
|
10
11
|
|
|
11
12
|
const { text, link } = editLinkObj;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
if (isOutline) {
|
|
15
|
+
return (
|
|
16
|
+
<Link href={link} className="rp-outline__action-row rp-edit-link">
|
|
17
|
+
<SvgWrapper icon={IconEdit} width="16" height="16" />
|
|
18
|
+
<span>{text}</span>
|
|
19
|
+
</Link>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
return (
|
|
15
|
-
<
|
|
24
|
+
<Link href={link} className="rp-edit-link">
|
|
16
25
|
{text}
|
|
17
|
-
</
|
|
26
|
+
</Link>
|
|
18
27
|
);
|
|
19
28
|
}
|
|
@@ -46,6 +46,9 @@ function HoverGroupItem({
|
|
|
46
46
|
href={item.link}
|
|
47
47
|
aria-label={item.text}
|
|
48
48
|
className="rp-hover-group__item__link"
|
|
49
|
+
lang={item.lang}
|
|
50
|
+
hrefLang={item.lang}
|
|
51
|
+
rel={item.rel}
|
|
49
52
|
>
|
|
50
53
|
{item.text}
|
|
51
54
|
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
@@ -65,7 +68,7 @@ function HoverGroupItem({
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
if ('link' in item) {
|
|
68
|
-
const { text, link } = item;
|
|
71
|
+
const { text, link, lang, rel } = item;
|
|
69
72
|
const isActiveItem = activeMatcher
|
|
70
73
|
? activeMatcher(item)
|
|
71
74
|
: matchNavbar(item, pathname);
|
|
@@ -84,12 +87,15 @@ function HoverGroupItem({
|
|
|
84
87
|
href={link}
|
|
85
88
|
aria-label={text}
|
|
86
89
|
className="rp-hover-group__item__link"
|
|
90
|
+
lang={lang}
|
|
91
|
+
hrefLang={lang}
|
|
92
|
+
rel={rel}
|
|
87
93
|
>
|
|
88
94
|
{text}
|
|
89
95
|
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
90
96
|
</Link>
|
|
91
97
|
) : (
|
|
92
|
-
<div className="rp-hover-group__item__link">
|
|
98
|
+
<div className="rp-hover-group__item__link" lang={lang}>
|
|
93
99
|
{text}
|
|
94
100
|
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
95
101
|
</div>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useI18n } from '@rspress/core/runtime';
|
|
2
|
+
import { IconCopy, IconSuccess, SvgWrapper } from '@theme';
|
|
3
|
+
import { useCallback, useRef, useState } from 'react';
|
|
4
|
+
import { useMdUrl } from './useMdUrl';
|
|
5
|
+
|
|
6
|
+
const cache = new Map<string, string>();
|
|
7
|
+
|
|
8
|
+
export function LlmsCopyRow() {
|
|
9
|
+
const t = useI18n();
|
|
10
|
+
const { pathname } = useMdUrl();
|
|
11
|
+
const [isLoading, setLoading] = useState(false);
|
|
12
|
+
const [isFinished, setFinished] = useState(false);
|
|
13
|
+
const timer = useRef<number | null>(null);
|
|
14
|
+
|
|
15
|
+
const handleClick = useCallback(async () => {
|
|
16
|
+
if (!pathname) return;
|
|
17
|
+
setLoading(true);
|
|
18
|
+
try {
|
|
19
|
+
const content: string =
|
|
20
|
+
cache.get(pathname) ?? (await fetch(pathname).then(res => res.text()));
|
|
21
|
+
cache.set(pathname, content);
|
|
22
|
+
await navigator.clipboard.writeText(content);
|
|
23
|
+
} finally {
|
|
24
|
+
setLoading(false);
|
|
25
|
+
setFinished(true);
|
|
26
|
+
if (timer.current) {
|
|
27
|
+
clearTimeout(timer.current);
|
|
28
|
+
timer.current = null;
|
|
29
|
+
}
|
|
30
|
+
timer.current = window.setTimeout(() => {
|
|
31
|
+
setFinished(false);
|
|
32
|
+
timer.current = null;
|
|
33
|
+
}, 1500);
|
|
34
|
+
}
|
|
35
|
+
}, [pathname]);
|
|
36
|
+
|
|
37
|
+
if (!pathname) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<button
|
|
43
|
+
className="rp-outline__action-row"
|
|
44
|
+
onClick={handleClick}
|
|
45
|
+
disabled={isLoading}
|
|
46
|
+
>
|
|
47
|
+
<SvgWrapper icon={isFinished ? IconSuccess : IconCopy} />
|
|
48
|
+
<span>{t('copyMarkdownText')}</span>
|
|
49
|
+
</button>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useI18n, useSite } from '@rspress/core/runtime';
|
|
2
|
+
import { IconExternalLink, SvgWrapper } from '@theme';
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import './LlmsOpenRow.scss';
|
|
5
|
+
import './LlmsViewOptions.scss';
|
|
6
|
+
import { useMdUrl } from './useMdUrl';
|
|
7
|
+
|
|
8
|
+
export function LlmsOpenRow() {
|
|
9
|
+
const t = useI18n();
|
|
10
|
+
const { pathname } = useMdUrl();
|
|
11
|
+
const { site } = useSite();
|
|
12
|
+
const llmsUI = site?.themeConfig?.llmsUI;
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
|
|
16
|
+
const options =
|
|
17
|
+
typeof llmsUI === 'object' && llmsUI?.viewOptions
|
|
18
|
+
? llmsUI.viewOptions
|
|
19
|
+
: (['chatgpt', 'claude'] as const);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
23
|
+
if (
|
|
24
|
+
containerRef.current &&
|
|
25
|
+
event.target &&
|
|
26
|
+
!containerRef.current.contains(event.target as Node)
|
|
27
|
+
) {
|
|
28
|
+
setIsOpen(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
32
|
+
return () => {
|
|
33
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const fullMarkdownUrl = useMemo(
|
|
38
|
+
() =>
|
|
39
|
+
typeof window !== 'undefined'
|
|
40
|
+
? new URL(pathname, window.location.origin).toString()
|
|
41
|
+
: '',
|
|
42
|
+
[pathname],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
|
|
46
|
+
|
|
47
|
+
const builtinItems: Record<
|
|
48
|
+
string,
|
|
49
|
+
{ title: string; href: string; icon: React.ReactNode }
|
|
50
|
+
> = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
chatgpt: {
|
|
53
|
+
title: t('openInText', { name: 'ChatGPT' }),
|
|
54
|
+
href: `https://chatgpt.com/?${new URLSearchParams({ hints: 'search', q })}`,
|
|
55
|
+
icon: (
|
|
56
|
+
<svg
|
|
57
|
+
role="img"
|
|
58
|
+
viewBox="0 0 24 24"
|
|
59
|
+
fill="currentColor"
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
+
width="16"
|
|
62
|
+
height="16"
|
|
63
|
+
>
|
|
64
|
+
<path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
|
|
65
|
+
</svg>
|
|
66
|
+
),
|
|
67
|
+
},
|
|
68
|
+
claude: {
|
|
69
|
+
title: t('openInText', { name: 'Claude' }),
|
|
70
|
+
href: `https://claude.ai/new?${new URLSearchParams({ q })}`,
|
|
71
|
+
icon: (
|
|
72
|
+
<svg
|
|
73
|
+
fill="currentColor"
|
|
74
|
+
role="img"
|
|
75
|
+
viewBox="0 0 24 24"
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
width="16"
|
|
78
|
+
height="16"
|
|
79
|
+
>
|
|
80
|
+
<path d="M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z" />
|
|
81
|
+
</svg>
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
[t, q],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (!pathname) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div ref={containerRef} className="rp-outline__open-in-wrapper">
|
|
94
|
+
<button
|
|
95
|
+
className="rp-outline__action-row"
|
|
96
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
97
|
+
>
|
|
98
|
+
<svg
|
|
99
|
+
width="16"
|
|
100
|
+
height="16"
|
|
101
|
+
viewBox="0 0 24 24"
|
|
102
|
+
fill="none"
|
|
103
|
+
stroke="currentColor"
|
|
104
|
+
strokeWidth="2"
|
|
105
|
+
strokeLinecap="round"
|
|
106
|
+
strokeLinejoin="round"
|
|
107
|
+
>
|
|
108
|
+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
|
|
109
|
+
<polyline points="15 3 21 3 21 9" />
|
|
110
|
+
<line x1="10" y1="14" x2="21" y2="3" />
|
|
111
|
+
</svg>
|
|
112
|
+
<span>{t('openInText', { name: 'chat' })}</span>
|
|
113
|
+
</button>
|
|
114
|
+
{isOpen && (
|
|
115
|
+
<div className="rp-llms-view-options__menu">
|
|
116
|
+
{options.map(option => {
|
|
117
|
+
let item: {
|
|
118
|
+
title: string;
|
|
119
|
+
href?: string;
|
|
120
|
+
icon?: React.ReactNode;
|
|
121
|
+
onClick?: () => void;
|
|
122
|
+
};
|
|
123
|
+
if (typeof option === 'string' && builtinItems[option]) {
|
|
124
|
+
item = builtinItems[option];
|
|
125
|
+
} else if (typeof option === 'object' && 'title' in option) {
|
|
126
|
+
item = option;
|
|
127
|
+
} else {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (item.href) {
|
|
131
|
+
return (
|
|
132
|
+
<a
|
|
133
|
+
key={item.title}
|
|
134
|
+
className="rp-llms-view-options__menu-item"
|
|
135
|
+
href={item.href}
|
|
136
|
+
target="_blank"
|
|
137
|
+
rel="noopener noreferrer"
|
|
138
|
+
onClick={() => setIsOpen(false)}
|
|
139
|
+
>
|
|
140
|
+
<span className="rp-llms-view-options__item-icon">
|
|
141
|
+
{item.icon}
|
|
142
|
+
</span>
|
|
143
|
+
<span>{item.title}</span>
|
|
144
|
+
<span className="rp-llms-view-options__external-icon">
|
|
145
|
+
<SvgWrapper icon={IconExternalLink} />
|
|
146
|
+
</span>
|
|
147
|
+
</a>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
key={item.title}
|
|
153
|
+
className="rp-llms-view-options__menu-item"
|
|
154
|
+
onClick={() => {
|
|
155
|
+
item.onClick?.();
|
|
156
|
+
setIsOpen(false);
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<span className="rp-llms-view-options__item-icon">
|
|
160
|
+
{item.icon}
|
|
161
|
+
</span>
|
|
162
|
+
<span>{item.title}</span>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
})}
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -27,7 +27,13 @@ export function NavMenuItemInner({
|
|
|
27
27
|
return (
|
|
28
28
|
<>
|
|
29
29
|
{'link' in menuItem && typeof menuItem.link === 'string' ? (
|
|
30
|
-
<Link
|
|
30
|
+
<Link
|
|
31
|
+
href={menuItem.link}
|
|
32
|
+
className="rp-nav-menu__item__container"
|
|
33
|
+
hrefLang={menuItem.lang}
|
|
34
|
+
lang={menuItem.lang}
|
|
35
|
+
rel={menuItem.rel}
|
|
36
|
+
>
|
|
31
37
|
{menuItem.text}
|
|
32
38
|
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
33
39
|
{children}
|
|
@@ -48,7 +48,14 @@ export function NavScreenLangs() {
|
|
|
48
48
|
{item.text}
|
|
49
49
|
</span>
|
|
50
50
|
) : (
|
|
51
|
-
<Link
|
|
51
|
+
<Link
|
|
52
|
+
key={item.text}
|
|
53
|
+
href={item.link}
|
|
54
|
+
className={className}
|
|
55
|
+
hrefLang={item.lang}
|
|
56
|
+
lang={item.lang}
|
|
57
|
+
rel="alternate"
|
|
58
|
+
>
|
|
52
59
|
{item.text}
|
|
53
60
|
</Link>
|
|
54
61
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useI18n } from '@rspress/core/runtime';
|
|
2
|
-
import '
|
|
2
|
+
import { IconScrollToTop, SvgWrapper, useReadPercent } from '@theme';
|
|
3
3
|
|
|
4
4
|
export function ScrollToTop() {
|
|
5
5
|
const scrollToTop = () => {
|
|
@@ -11,40 +11,18 @@ export function ScrollToTop() {
|
|
|
11
11
|
|
|
12
12
|
const t = useI18n();
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
viewBox="0 0 16 16"
|
|
20
|
-
fill="none"
|
|
21
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
22
|
-
>
|
|
23
|
-
<path
|
|
24
|
-
fillRule="evenodd"
|
|
25
|
-
clipRule="evenodd"
|
|
26
|
-
d="M7.99967 14.6667C11.6816 14.6667 14.6663 11.6819 14.6663 8.00001C14.6663 4.31811 11.6816 1.33334 7.99967 1.33334C4.31777 1.33334 1.33301 4.31811 1.33301 8.00001C1.33301 11.6819 4.31777 14.6667 7.99967 14.6667Z"
|
|
27
|
-
stroke="currentColor"
|
|
28
|
-
strokeOpacity="0.8"
|
|
29
|
-
strokeWidth="1.33333"
|
|
30
|
-
/>
|
|
31
|
-
<path
|
|
32
|
-
d="M7.99967 14.6667C11.6816 14.6667 14.6663 11.6819 14.6663 8.00001C14.6663 4.31811 11.6816 1.33334 7.99967 1.33334C4.31777 1.33334 1.33301 4.31811 1.33301 8.00001C1.33301 11.6819 4.31777 14.6667 7.99967 14.6667Z"
|
|
33
|
-
stroke="currentColor"
|
|
34
|
-
strokeOpacity="0.8"
|
|
35
|
-
strokeWidth="1.33333"
|
|
36
|
-
strokeLinejoin="round"
|
|
37
|
-
/>
|
|
38
|
-
<path
|
|
39
|
-
d="M11 9L8 6L5 9"
|
|
40
|
-
stroke="currentColor"
|
|
41
|
-
strokeOpacity="0.8"
|
|
42
|
-
strokeWidth="1.33333"
|
|
43
|
-
strokeLinecap="round"
|
|
44
|
-
strokeLinejoin="round"
|
|
45
|
-
/>
|
|
46
|
-
</svg>
|
|
14
|
+
const [, scrollTop] = useReadPercent();
|
|
15
|
+
|
|
16
|
+
if (scrollTop < 100) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
47
19
|
|
|
20
|
+
return (
|
|
21
|
+
<button
|
|
22
|
+
className="rp-outline__action-row rp-scroll-to-top"
|
|
23
|
+
onClick={scrollToTop}
|
|
24
|
+
>
|
|
25
|
+
<SvgWrapper icon={IconScrollToTop} width="16" height="16" />
|
|
48
26
|
<span>{t('scrollToTopText')}</span>
|
|
49
27
|
</button>
|
|
50
28
|
);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
&__title {
|
|
11
11
|
padding-left: var(--rp-outline-padding-x);
|
|
12
12
|
padding-right: var(--rp-outline-padding-x);
|
|
13
|
+
flex-shrink: 0;
|
|
13
14
|
|
|
14
15
|
font-size: 14px;
|
|
15
16
|
font-weight: 700;
|
|
@@ -17,7 +18,6 @@
|
|
|
17
18
|
line-height: 32px;
|
|
18
19
|
font-style: normal;
|
|
19
20
|
color: var(--rp-c-text-1);
|
|
20
|
-
margin-bottom: 4px;
|
|
21
21
|
display: inline-flex;
|
|
22
22
|
align-items: center;
|
|
23
23
|
gap: 4px;
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
&__divider {
|
|
30
30
|
margin-left: var(--rp-outline-padding-x);
|
|
31
31
|
margin-right: var(--rp-outline-padding-x);
|
|
32
|
+
flex-shrink: 0;
|
|
32
33
|
|
|
33
34
|
height: 1px;
|
|
34
35
|
background: var(--rp-c-divider-light);
|
|
@@ -37,22 +38,57 @@
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
&__toc {
|
|
40
|
-
padding
|
|
41
|
-
padding-right: var(--rp-outline-padding-x);
|
|
41
|
+
padding: 4px var(--rp-outline-padding-x);
|
|
42
42
|
|
|
43
43
|
display: flex;
|
|
44
44
|
flex-direction: column;
|
|
45
45
|
flex: 1;
|
|
46
|
+
min-height: 0;
|
|
47
|
+
max-height: 70vh;
|
|
48
|
+
overflow: auto scroll;
|
|
49
|
+
scrollbar-width: none;
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
mask-image: linear-gradient(#0000, #fff 12px calc(100% - 12px), #0000);
|
|
52
|
+
|
|
53
|
+
// limit height on mobile where outline is a floating panel
|
|
48
54
|
@media (max-width: 1280px) {
|
|
49
55
|
max-height: 60vh;
|
|
50
|
-
overflow: auto scroll;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
&__bottom {
|
|
55
60
|
padding-left: var(--rp-outline-padding-x);
|
|
56
61
|
padding-right: var(--rp-outline-padding-x);
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
gap: 10px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&__action-row {
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
font-style: normal;
|
|
72
|
+
font-weight: 400;
|
|
73
|
+
line-height: 20px;
|
|
74
|
+
color: var(--rp-c-text-2);
|
|
75
|
+
background: transparent;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 8px;
|
|
79
|
+
border: none;
|
|
80
|
+
padding: 0;
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
transition: color 0.2s;
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
color: var(--rp-c-text-1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
svg {
|
|
89
|
+
width: 16px;
|
|
90
|
+
height: 16px;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
}
|
|
57
93
|
}
|
|
58
94
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { useI18n, useSite } from '@rspress/core/runtime';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
EditLink,
|
|
4
|
+
LlmsCopyRow,
|
|
5
|
+
LlmsOpenRow,
|
|
6
|
+
ReadPercent,
|
|
7
|
+
Toc,
|
|
8
|
+
useDynamicToc,
|
|
9
|
+
} from '@theme';
|
|
3
10
|
import './index.scss';
|
|
4
11
|
import { ScrollToTop } from './ScrollToTop';
|
|
5
12
|
|
|
@@ -9,7 +16,7 @@ export function Outline() {
|
|
|
9
16
|
const headers = useDynamicToc();
|
|
10
17
|
const {
|
|
11
18
|
site: {
|
|
12
|
-
themeConfig: { enableScrollToTop = true },
|
|
19
|
+
themeConfig: { enableScrollToTop = true, llmsUI },
|
|
13
20
|
},
|
|
14
21
|
} = useSite();
|
|
15
22
|
|
|
@@ -17,6 +24,9 @@ export function Outline() {
|
|
|
17
24
|
return <></>;
|
|
18
25
|
}
|
|
19
26
|
|
|
27
|
+
const placement =
|
|
28
|
+
typeof llmsUI === 'object' ? (llmsUI?.placement ?? 'title') : 'title';
|
|
29
|
+
|
|
20
30
|
return (
|
|
21
31
|
<div className="rp-outline">
|
|
22
32
|
<div className="rp-outline__title">
|
|
@@ -28,6 +38,13 @@ export function Outline() {
|
|
|
28
38
|
</nav>
|
|
29
39
|
<div className="rp-outline__divider" />
|
|
30
40
|
<div className="rp-outline__bottom">
|
|
41
|
+
<EditLink isOutline />
|
|
42
|
+
{process.env.ENABLE_LLMS_UI && placement === 'outline' && (
|
|
43
|
+
<>
|
|
44
|
+
<LlmsCopyRow />
|
|
45
|
+
<LlmsOpenRow />
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
31
48
|
{enableScrollToTop && <ScrollToTop />}
|
|
32
49
|
</div>
|
|
33
50
|
</div>
|