@rspress/core 2.0.17 → 2.0.18
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~execa.js +1 -1
- package/dist/{7448.js → 3553.js} +2 -2
- package/dist/{8629.js → 5871.js} +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +1 -1
- package/dist/eject-theme/components/HomeFeature/index.scss +1 -0
- package/dist/eject-theme/components/HomeFeature/index.tsx +1 -1
- package/dist/eject-theme/components/HoverGroup/index.scss +9 -0
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +23 -0
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +15 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +51 -64
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +65 -51
- package/dist/eject-theme/components/Llms/index.tsx +6 -1
- package/dist/eject-theme/components/Outline/index.tsx +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +16 -5
- package/dist/node/llms.d.ts +3 -0
- package/dist/node/llms.js +8 -0
- package/dist/node/route/RoutePage.js +5 -3
- package/dist/node/route/RouteService.js +8 -3
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/route/routeChunkAssets.d.ts +15 -0
- package/dist/node/route/routeChunkAssets.js +56 -0
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/alternateLinks.d.ts +7 -0
- package/dist/node/ssg/alternateLinks.js +40 -0
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.d.ts +3 -1
- package/dist/node/ssg/renderHtmlTemplate.js +25 -3
- package/dist/node/ssg/renderPage.d.ts +3 -1
- package/dist/node/ssg/renderPage.js +3 -3
- package/dist/node/ssg/renderPageWorker.js +4 -4
- package/dist/node/ssg/renderPages.d.ts +3 -2
- package/dist/node/ssg/renderPages.js +15 -10
- package/dist/node/ssg/rsbuildPluginCSR.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginCSR.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +3 -3
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.d.ts +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.js +49 -35
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.d.ts +1 -1
- package/dist/node/utils/createHash.js +3 -3
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/App.js +2 -0
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/utils.d.ts +2 -1
- package/dist/runtime/utils.js +5 -2
- package/dist/theme/assets/anthropic.js +15 -0
- package/dist/theme/assets/open-in-chat.js +19 -0
- package/dist/theme/assets/openai.js +15 -0
- package/dist/theme/components/DocContent/docComponents/title.js +1 -1
- package/dist/theme/components/HomeFeature/index.css +1 -0
- package/dist/theme/components/HomeFeature/index.js +32 -34
- package/dist/theme/components/HoverGroup/index.css +7 -0
- package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsHiddenHint.js +18 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +31 -57
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +6 -4
- package/dist/theme/components/Llms/LlmsViewOptions.js +28 -45
- package/dist/theme/components/Llms/index.d.ts +2 -1
- package/dist/theme/components/Llms/index.js +1 -0
- package/dist/theme/components/Outline/index.js +1 -1
- package/dist/theme/icons.d.ts +4 -1
- package/dist/theme/icons.js +8 -2
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/package.json +4 -4
- /package/dist/{8629.js.LICENSE.txt → 5871.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchPath, getSidebarDataGroup } from "../../../
|
|
1
|
+
import { matchPath, getSidebarDataGroup } from "../../../5871.js";
|
|
2
2
|
import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
|
|
3
3
|
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
4
4
|
const base = config.base ?? '/';
|
|
@@ -56,7 +56,7 @@ async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
|
56
56
|
others.push(routePath);
|
|
57
57
|
});
|
|
58
58
|
for (const routeGroup of routeGroups)organizeBySidebar(sidebar, routeGroup);
|
|
59
|
-
const llmsTxtContent = await generateLlmsTxt(routeGroups, others, navList, config.title, config.description,
|
|
59
|
+
const llmsTxtContent = await generateLlmsTxt(routeGroups, others, navList, config.title, config.description, base, config.siteOrigin, routeService, lang, version, 'object' == typeof config.llms ? config.llms.llmsTxt : void 0);
|
|
60
60
|
const llmsFullTxtContent = generateLlmsFullTxt(routeGroups, navList, others, base, config.siteOrigin, mdContents);
|
|
61
61
|
const langPrefix = defaultLang === lang ? '' : `${lang}/`;
|
|
62
62
|
const versionPrefix = isMultiVersion && version !== defaultVersion ? `${version}/` : '';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type NavItemWithLink } from '@rspress/shared';
|
|
1
|
+
import { type LlmsTxtRenderer, type NavItemWithLink } from '@rspress/shared';
|
|
2
2
|
import type { RouteService } from '../../route/RouteService.js';
|
|
3
3
|
declare function routePathToMdPath(routePath: string, base: string, siteOrigin?: string): string;
|
|
4
4
|
declare function generateLlmsTxt(routeGroups: string[][], others: string[], navList: {
|
|
5
5
|
text: string;
|
|
6
|
-
}[], title: string | undefined, description: string | undefined, base: string, siteOrigin: string | undefined, routeService: RouteService): Promise<string>;
|
|
6
|
+
}[], title: string | undefined, description: string | undefined, base: string, siteOrigin: string | undefined, routeService: RouteService, lang: string, version: string, renderLlmsTxt?: LlmsTxtRenderer): Promise<string>;
|
|
7
7
|
declare function generateLlmsFullTxt(routeGroups: string[][], navList: (NavItemWithLink & {
|
|
8
8
|
lang: string;
|
|
9
9
|
})[], others: string[], base: string, siteOrigin: string | undefined, mdContents: Map<string, string>): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../
|
|
1
|
+
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../5871.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base, siteOrigin) {
|
|
4
4
|
let url = routePath;
|
|
@@ -6,48 +6,62 @@ function routePathToMdPath(routePath, base, siteOrigin) {
|
|
|
6
6
|
url = url.replace(/\.html$/, '.md');
|
|
7
7
|
return withSiteOrigin(withBase(url, base), siteOrigin);
|
|
8
8
|
}
|
|
9
|
-
async function generateLlmsTxt(routeGroups, others, navList, title, description, base, siteOrigin, routeService) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
async function genH2Part(nav, routes) {
|
|
14
|
-
const lines = [];
|
|
15
|
-
const { text } = nav;
|
|
16
|
-
if (0 === routes.length) return lines;
|
|
17
|
-
const routeLines = (await Promise.all(routes.map(async (route)=>{
|
|
9
|
+
async function generateLlmsTxt(routeGroups, others, navList, title, description, base, siteOrigin, routeService, lang, version, renderLlmsTxt) {
|
|
10
|
+
async function generateSection(sectionTitle, routes) {
|
|
11
|
+
if (0 === routes.length) return;
|
|
12
|
+
const pages = (await Promise.all(routes.map(async (route)=>{
|
|
18
13
|
const routePage = routeService.getRoutePageByRoutePath(route);
|
|
19
|
-
const { lang, routePath, absolutePath } = routePage.routeMeta;
|
|
20
|
-
if ('/' ===
|
|
14
|
+
const { lang: pageLang, routePath, pureRoutePath, absolutePath, version: pageVersion } = routePage.routeMeta;
|
|
15
|
+
if ('/' === pureRoutePath) return;
|
|
21
16
|
const pageInfo = routePage.pageIndexInfo;
|
|
22
|
-
let title;
|
|
23
|
-
let description;
|
|
24
|
-
if (
|
|
25
|
-
title = pageInfo.title;
|
|
26
|
-
description = pageInfo.description;
|
|
27
|
-
} else {
|
|
17
|
+
let title = pageInfo?.title;
|
|
18
|
+
let description = pageInfo?.description;
|
|
19
|
+
if (!title) {
|
|
28
20
|
const info = await extractInfoFromFrontmatterWithAbsolutePath(absolutePath, routeService.getDocsDir());
|
|
29
21
|
title = info.title;
|
|
30
|
-
description
|
|
22
|
+
description ??= info.description;
|
|
31
23
|
}
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
return {
|
|
25
|
+
routePath,
|
|
26
|
+
link: routePathToMdPath(routePath, base, siteOrigin),
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
frontmatter: pageInfo?.frontmatter ?? {},
|
|
30
|
+
lang: pageLang,
|
|
31
|
+
version: pageVersion
|
|
32
|
+
};
|
|
33
|
+
}))).filter((page)=>Boolean(page));
|
|
34
|
+
if (0 === pages.length) return;
|
|
35
|
+
return {
|
|
36
|
+
title: sectionTitle,
|
|
37
|
+
pages
|
|
38
|
+
};
|
|
40
39
|
}
|
|
41
|
-
const
|
|
40
|
+
const navSections = await Promise.all(navList.map(async (nav, i)=>{
|
|
42
41
|
const routes = routeGroups[i];
|
|
43
|
-
|
|
44
|
-
return h2Part;
|
|
42
|
+
return generateSection(nav.text, routes);
|
|
45
43
|
}));
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const otherSection = await generateSection('Others', others);
|
|
45
|
+
const sections = [
|
|
46
|
+
...navSections,
|
|
47
|
+
otherSection
|
|
48
|
+
].filter((section)=>Boolean(section));
|
|
49
|
+
if (renderLlmsTxt) return renderLlmsTxt({
|
|
50
|
+
title,
|
|
51
|
+
description,
|
|
52
|
+
lang,
|
|
53
|
+
version,
|
|
54
|
+
base,
|
|
55
|
+
siteOrigin,
|
|
56
|
+
sections
|
|
57
|
+
});
|
|
58
|
+
if (!title) logger.warn('No `title` is configured in your Rspress setup. Please set `title` in rspress.config.ts so llms.txt can include an appropriate heading.');
|
|
59
|
+
const summary = title ? `# ${title}${description ? `\n\n> ${description}` : ''}` : '';
|
|
60
|
+
const lines = [];
|
|
61
|
+
for (const section of sections){
|
|
62
|
+
lines.push(`\n## ${section.title}\n`);
|
|
63
|
+
lines.push(...section.pages.map((page)=>`- [${page.title}](${page.link})${page.description ? `: ${page.description}` : ''}`));
|
|
64
|
+
}
|
|
51
65
|
let llmsTxt;
|
|
52
66
|
llmsTxt = summary ? lines.length > 0 ? `${summary}\n${lines.join('\n')}` : summary : lines.join('\n').trimStart();
|
|
53
67
|
return llmsTxt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../4538.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../5871.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../4538.js";
|
|
3
|
-
import { logger } from "../../
|
|
4
|
-
import { pMap } from "../../
|
|
3
|
+
import { logger } from "../../5871.js";
|
|
4
|
+
import { pMap } from "../../3553.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
7
7
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { writeFile, mkdir, rm, join, isDebugMode } from "../../5871.js";
|
|
2
2
|
import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function createHash(str: string): string;
|
|
1
|
+
export declare function createHash(str: string, length?: number): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createHash as external_node_crypto_createHash } from "../../
|
|
2
|
-
function createHash(str) {
|
|
3
|
-
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0,
|
|
1
|
+
import { createHash as external_node_crypto_createHash } from "../../5871.js";
|
|
2
|
+
function createHash(str, length = 8) {
|
|
3
|
+
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
|
|
4
4
|
}
|
|
5
5
|
export { createHash };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../5871.js";
|
|
2
2
|
import { createError } from "./error.js";
|
|
3
3
|
import { importStatementRegex } from "../constants.js";
|
|
4
4
|
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../4538.js";
|
|
3
|
-
import { node_path, core_rspack, logger } from "../../
|
|
3
|
+
import { node_path, core_rspack, logger } from "../../5871.js";
|
|
4
4
|
import { pathExists, readJson } from "./fs.js";
|
|
5
5
|
import { PACKAGE_ROOT } from "../constants.js";
|
|
6
6
|
import { hintReactVersion } from "../logger/hint.js";
|
package/dist/runtime/App.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PageContext, useLocation } from "@rspress/core/runtime";
|
|
3
3
|
import { Layout, Root } from "@rspress/core/theme";
|
|
4
|
+
import { LlmsHiddenHint } from "@rspress/core/theme-original";
|
|
4
5
|
import react, { useContext, useLayoutEffect } from "react";
|
|
5
6
|
import virtual_global_components from "virtual-global-components";
|
|
6
7
|
import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
|
|
@@ -34,6 +35,7 @@ function App() {
|
|
|
34
35
|
});
|
|
35
36
|
return /*#__PURE__*/ jsxs(Root, {
|
|
36
37
|
children: [
|
|
38
|
+
import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHiddenHint, {}),
|
|
37
39
|
/*#__PURE__*/ jsx(Layout, {}),
|
|
38
40
|
!hideGlobalUIComponents && virtual_global_components.map((componentInfo, index)=>{
|
|
39
41
|
if (Array.isArray(componentInfo)) {
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -20,4 +20,4 @@ export { useWindowSize } from './hooks/useWindowSize.js';
|
|
|
20
20
|
export { initPageData, warmPageData } from './initPageData.js';
|
|
21
21
|
export { NoSSR } from './NoSSR.js';
|
|
22
22
|
export { isActive, pathnameToRouteService, preloadLink } from './route.js';
|
|
23
|
-
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, } from './utils.js';
|
|
23
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, withSiteOrigin, } from './utils.js';
|
package/dist/runtime/index.js
CHANGED
|
@@ -20,4 +20,4 @@ export { useWindowSize } from "./hooks/useWindowSize.js";
|
|
|
20
20
|
export { initPageData, warmPageData } from "./initPageData.js";
|
|
21
21
|
export { NoSSR } from "./NoSSR.js";
|
|
22
22
|
export { isActive, pathnameToRouteService, preloadLink } from "./route.js";
|
|
23
|
-
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase } from "./utils.js";
|
|
23
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, withSiteOrigin } from "./utils.js";
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addLeadingSlash, addTrailingSlash, isProduction, removeTrailingSlash } from '@rspress/shared';
|
|
2
2
|
declare function withBase(url?: string): string;
|
|
3
|
+
declare function withSiteOrigin(url: string): string;
|
|
3
4
|
declare function removeBase(url: string): string;
|
|
4
5
|
declare function isEqualPath(a: string, b: string): boolean;
|
|
5
6
|
declare function normalizeHrefInRuntime(link: string): string;
|
|
@@ -9,4 +10,4 @@ declare function normalizeHrefInRuntime(link: string): string;
|
|
|
9
10
|
declare function cleanUrlByConfig(link: string): string;
|
|
10
11
|
declare function normalizeImagePath(imagePath: string): string;
|
|
11
12
|
declare function routePathToMdPath(routePath: string): string;
|
|
12
|
-
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, };
|
|
13
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, withSiteOrigin, };
|
package/dist/runtime/utils.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { addLeadingSlash, addTrailingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, removeBase, removeHash, removeTrailingSlash, withBase } from "@rspress/shared";
|
|
1
|
+
import { addLeadingSlash, addTrailingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, removeBase, removeHash, removeTrailingSlash, withBase, withSiteOrigin } from "@rspress/shared";
|
|
2
2
|
import virtual_site_data from "virtual-site-data";
|
|
3
3
|
function utils_withBase(url = '/') {
|
|
4
4
|
return withBase(url, virtual_site_data.base);
|
|
5
5
|
}
|
|
6
|
+
function utils_withSiteOrigin(url) {
|
|
7
|
+
return withSiteOrigin(url, virtual_site_data.siteOrigin);
|
|
8
|
+
}
|
|
6
9
|
function utils_removeBase(url) {
|
|
7
10
|
return removeBase(url, virtual_site_data.base);
|
|
8
11
|
}
|
|
@@ -31,4 +34,4 @@ function routePathToMdPath(routePath) {
|
|
|
31
34
|
function isAbsoluteUrl(path) {
|
|
32
35
|
return isExternalUrl(path) || isDataUrl(path) || path.startsWith('//');
|
|
33
36
|
}
|
|
34
|
-
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeTrailingSlash, routePathToMdPath, utils_removeBase as removeBase, utils_withBase as withBase };
|
|
37
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeTrailingSlash, routePathToMdPath, utils_removeBase as removeBase, utils_withBase as withBase, utils_withSiteOrigin as withSiteOrigin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgAnthropic = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
11
|
+
d: "M17.304 3.541h-3.672l6.696 16.918H24Zm-10.608 0L0 20.459h3.744l1.37-3.553h7.005l1.369 3.553h3.744L10.536 3.541Zm-.371 10.223L8.616 7.82l2.291 5.945Z"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
var anthropic = SvgAnthropic;
|
|
15
|
+
export default anthropic;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgOpenInChat = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeLinecap: "round",
|
|
13
|
+
strokeLinejoin: "round",
|
|
14
|
+
strokeWidth: 2,
|
|
15
|
+
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
var open_in_chat = SvgOpenInChat;
|
|
19
|
+
export default open_in_chat;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgOpenai = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
11
|
+
d: "M22.282 9.821a5.99 5.99 0 0 0-.516-4.91 6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.99 5.99 0 0 0-3.998 2.9 6.05 6.05 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.05 6.05 0 0 0 6.515 2.9A5.99 5.99 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206 6 6 0 0 0 3.997-2.9 6.06 6.06 0 0 0-.747-7.073zM13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023-.141-.085-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08-4.778 2.758a.8.8 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5Z"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
var openai = SvgOpenai;
|
|
15
|
+
export default openai;
|
|
@@ -21,7 +21,7 @@ const H1 = (props)=>{
|
|
|
21
21
|
})
|
|
22
22
|
]
|
|
23
23
|
}),
|
|
24
|
-
|
|
24
|
+
import.meta.env.ENABLE_LLMS_UI && 'title' === placement && /*#__PURE__*/ jsxs(LlmsContainer, {
|
|
25
25
|
children: [
|
|
26
26
|
/*#__PURE__*/ jsx(LlmsCopyButton, {}),
|
|
27
27
|
/*#__PURE__*/ jsx(LlmsViewOptions, {})
|
|
@@ -24,44 +24,42 @@ function HomeFeatureItem({ feature }) {
|
|
|
24
24
|
const { icon, title, details, link } = feature;
|
|
25
25
|
const { innerProps, outerProps, outerRef, shineDom } = useCardAnimation();
|
|
26
26
|
const navigate = useLinkNavigate();
|
|
27
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/ jsx("div", {
|
|
28
28
|
...outerProps,
|
|
29
29
|
className: `rp-home-feature__item ${getGridClass(feature)}`,
|
|
30
30
|
ref: outerRef,
|
|
31
|
-
children:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
icon: icon
|
|
48
|
-
})
|
|
49
|
-
}) : null,
|
|
50
|
-
/*#__PURE__*/ jsx("h2", {
|
|
51
|
-
className: "rp-home-feature__title",
|
|
52
|
-
children: title
|
|
31
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
32
|
+
className: "rp-home-feature__item-wrapper",
|
|
33
|
+
...innerProps,
|
|
34
|
+
children: /*#__PURE__*/ jsxs("article", {
|
|
35
|
+
className: `rp-home-feature__card ${link ? 'rp-home-feature__card--clickable' : ''}`,
|
|
36
|
+
onClick: ()=>{
|
|
37
|
+
if (link) navigate(link);
|
|
38
|
+
},
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ jsxs("div", {
|
|
41
|
+
className: "rp-home-feature__title-wrapper",
|
|
42
|
+
children: [
|
|
43
|
+
icon ? /*#__PURE__*/ jsx("div", {
|
|
44
|
+
className: "rp-home-feature__icon",
|
|
45
|
+
children: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
46
|
+
icon: icon
|
|
53
47
|
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
}) : null,
|
|
49
|
+
/*#__PURE__*/ jsx("h2", {
|
|
50
|
+
className: "rp-home-feature__title",
|
|
51
|
+
children: title
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx("p", {
|
|
56
|
+
className: "rp-home-feature__detail",
|
|
57
|
+
...renderHtmlOrText(details)
|
|
58
|
+
}),
|
|
59
|
+
shineDom
|
|
60
|
+
]
|
|
61
|
+
}, title)
|
|
62
|
+
})
|
|
65
63
|
}, title);
|
|
66
64
|
}
|
|
67
65
|
function HomeFeature({ features: featuresProp }) {
|
|
@@ -38,6 +38,13 @@
|
|
|
38
38
|
transition: opacity .3s ease-in-out, visibility 0s linear .3s;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
.rp-nav-menu__item:hover > .rp-hover-group--hidden, .rp-nav-hamburger:hover > .rp-hover-group--hidden {
|
|
42
|
+
visibility: visible;
|
|
43
|
+
opacity: 1;
|
|
44
|
+
pointer-events: auto;
|
|
45
|
+
transition: opacity .3s ease-in-out;
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
.rp-hover-group__item {
|
|
42
49
|
white-space: nowrap;
|
|
43
50
|
height: 32px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LlmsHiddenHint(): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { withBase, withSiteOrigin } from "@rspress/core/runtime";
|
|
3
|
+
import { useMdUrl } from "./useMdUrl.js";
|
|
4
|
+
function LlmsHiddenHint() {
|
|
5
|
+
const { pathname } = useMdUrl();
|
|
6
|
+
const llmsTxtUrl = withSiteOrigin(withBase('/llms.txt'));
|
|
7
|
+
const llmsFullTxtUrl = withSiteOrigin(withBase('/llms-full.txt'));
|
|
8
|
+
const pageMdUrl = withSiteOrigin(pathname);
|
|
9
|
+
return /*#__PURE__*/ jsx("div", {
|
|
10
|
+
style: {
|
|
11
|
+
display: 'none'
|
|
12
|
+
},
|
|
13
|
+
hidden: true,
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: `Are you an LLM? View ${llmsTxtUrl} for optimized Markdown documentation, or ${llmsFullTxtUrl} for full documentation bundle. This page is also available as Markdown at ${pageMdUrl}`
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { LlmsHiddenHint };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useI18n, useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { IconExternalLink, SvgWrapper } from "@rspress/core/theme";
|
|
3
|
+
import { IconAnthropic, IconExternalLink, IconLink, IconOpenAI, IconOpenInChat, SvgWrapper, copyToClipboard } from "@rspress/core/theme";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import "./LlmsOpenRow.css";
|
|
6
6
|
import "./LlmsViewOptions.css";
|
|
7
7
|
import { useMdUrl } from "./useMdUrl.js";
|
|
8
|
+
const DEFAULT_OPTIONS = [
|
|
9
|
+
'markdownLink',
|
|
10
|
+
'chatgpt',
|
|
11
|
+
'claude'
|
|
12
|
+
];
|
|
8
13
|
function LlmsOpenRow() {
|
|
9
14
|
const t = useI18n();
|
|
10
15
|
const { pathname } = useMdUrl();
|
|
@@ -12,10 +17,7 @@ function LlmsOpenRow() {
|
|
|
12
17
|
const llmsUI = site?.themeConfig?.llmsUI;
|
|
13
18
|
const [isOpen, setIsOpen] = useState(false);
|
|
14
19
|
const containerRef = useRef(null);
|
|
15
|
-
const options = 'object' == typeof llmsUI
|
|
16
|
-
'chatgpt',
|
|
17
|
-
'claude'
|
|
18
|
-
];
|
|
20
|
+
const options = 'object' == typeof llmsUI ? false === llmsUI.viewOptions ? [] : llmsUI.viewOptions ?? DEFAULT_OPTIONS : DEFAULT_OPTIONS;
|
|
19
21
|
useEffect(()=>{
|
|
20
22
|
const handleClickOutside = (event)=>{
|
|
21
23
|
if (containerRef.current && event.target && !containerRef.current.contains(event.target)) setIsOpen(false);
|
|
@@ -30,6 +32,15 @@ function LlmsOpenRow() {
|
|
|
30
32
|
]);
|
|
31
33
|
const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
|
|
32
34
|
const builtinItems = useMemo(()=>({
|
|
35
|
+
markdownLink: {
|
|
36
|
+
title: t('copyMarkdownLinkText'),
|
|
37
|
+
icon: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
38
|
+
icon: IconLink
|
|
39
|
+
}),
|
|
40
|
+
onClick: ()=>{
|
|
41
|
+
copyToClipboard(fullMarkdownUrl);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
33
44
|
chatgpt: {
|
|
34
45
|
title: t('openInText', {
|
|
35
46
|
name: 'ChatGPT'
|
|
@@ -38,16 +49,8 @@ function LlmsOpenRow() {
|
|
|
38
49
|
hints: 'search',
|
|
39
50
|
q
|
|
40
51
|
})}`,
|
|
41
|
-
icon: /*#__PURE__*/ jsx(
|
|
42
|
-
|
|
43
|
-
viewBox: "0 0 24 24",
|
|
44
|
-
fill: "currentColor",
|
|
45
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
46
|
-
width: "16",
|
|
47
|
-
height: "16",
|
|
48
|
-
children: /*#__PURE__*/ jsx("path", {
|
|
49
|
-
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"
|
|
50
|
-
})
|
|
52
|
+
icon: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
53
|
+
icon: IconOpenAI
|
|
51
54
|
})
|
|
52
55
|
},
|
|
53
56
|
claude: {
|
|
@@ -57,23 +60,20 @@ function LlmsOpenRow() {
|
|
|
57
60
|
href: `https://claude.ai/new?${new URLSearchParams({
|
|
58
61
|
q
|
|
59
62
|
})}`,
|
|
60
|
-
icon: /*#__PURE__*/ jsx(
|
|
61
|
-
|
|
62
|
-
role: "img",
|
|
63
|
-
viewBox: "0 0 24 24",
|
|
64
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
-
width: "16",
|
|
66
|
-
height: "16",
|
|
67
|
-
children: /*#__PURE__*/ jsx("path", {
|
|
68
|
-
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"
|
|
69
|
-
})
|
|
63
|
+
icon: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
64
|
+
icon: IconAnthropic
|
|
70
65
|
})
|
|
71
66
|
}
|
|
72
67
|
}), [
|
|
68
|
+
fullMarkdownUrl,
|
|
73
69
|
t,
|
|
74
70
|
q
|
|
75
71
|
]);
|
|
76
|
-
|
|
72
|
+
const renderableItems = useMemo(()=>options.map((option)=>builtinItems[option] ?? null).filter((item)=>null !== item), [
|
|
73
|
+
options,
|
|
74
|
+
builtinItems
|
|
75
|
+
]);
|
|
76
|
+
if (!pathname || 0 === renderableItems.length) return null;
|
|
77
77
|
return /*#__PURE__*/ jsxs("div", {
|
|
78
78
|
ref: containerRef,
|
|
79
79
|
className: "rp-outline__open-in-wrapper",
|
|
@@ -82,29 +82,8 @@ function LlmsOpenRow() {
|
|
|
82
82
|
className: "rp-outline__action-row",
|
|
83
83
|
onClick: ()=>setIsOpen(!isOpen),
|
|
84
84
|
children: [
|
|
85
|
-
/*#__PURE__*/
|
|
86
|
-
|
|
87
|
-
height: "16",
|
|
88
|
-
viewBox: "0 0 24 24",
|
|
89
|
-
fill: "none",
|
|
90
|
-
stroke: "currentColor",
|
|
91
|
-
strokeWidth: "2",
|
|
92
|
-
strokeLinecap: "round",
|
|
93
|
-
strokeLinejoin: "round",
|
|
94
|
-
children: [
|
|
95
|
-
/*#__PURE__*/ jsx("path", {
|
|
96
|
-
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
|
|
97
|
-
}),
|
|
98
|
-
/*#__PURE__*/ jsx("polyline", {
|
|
99
|
-
points: "15 3 21 3 21 9"
|
|
100
|
-
}),
|
|
101
|
-
/*#__PURE__*/ jsx("line", {
|
|
102
|
-
x1: "10",
|
|
103
|
-
y1: "14",
|
|
104
|
-
x2: "21",
|
|
105
|
-
y2: "3"
|
|
106
|
-
})
|
|
107
|
-
]
|
|
85
|
+
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
86
|
+
icon: IconOpenInChat
|
|
108
87
|
}),
|
|
109
88
|
/*#__PURE__*/ jsx("span", {
|
|
110
89
|
children: t('openInText', {
|
|
@@ -115,13 +94,7 @@ function LlmsOpenRow() {
|
|
|
115
94
|
}),
|
|
116
95
|
isOpen && /*#__PURE__*/ jsx("div", {
|
|
117
96
|
className: "rp-llms-view-options__menu",
|
|
118
|
-
children:
|
|
119
|
-
let item;
|
|
120
|
-
if ('string' == typeof option && builtinItems[option]) item = builtinItems[option];
|
|
121
|
-
else {
|
|
122
|
-
if ('object' != typeof option || !('title' in option)) return null;
|
|
123
|
-
item = option;
|
|
124
|
-
}
|
|
97
|
+
children: renderableItems.map((item)=>{
|
|
125
98
|
if (item.href) return /*#__PURE__*/ jsxs("a", {
|
|
126
99
|
className: "rp-llms-view-options__menu-item",
|
|
127
100
|
href: item.href,
|
|
@@ -144,7 +117,8 @@ function LlmsOpenRow() {
|
|
|
144
117
|
})
|
|
145
118
|
]
|
|
146
119
|
}, item.title);
|
|
147
|
-
return /*#__PURE__*/ jsxs("
|
|
120
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
121
|
+
type: "button",
|
|
148
122
|
className: "rp-llms-view-options__menu-item",
|
|
149
123
|
onClick: ()=>{
|
|
150
124
|
item.onClick?.();
|