@rspress/core 2.0.13 → 2.0.15
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/0~rslib-runtime.js +9 -5
- package/dist/3358.js +1 -1
- package/dist/5580.js +2 -2
- package/dist/{2633.js → 6010.js} +12 -9
- package/dist/6646.js +3 -0
- package/dist/8005.js +1 -1
- package/dist/{7275.js → 9958.js} +3 -2
- package/dist/cli/index.js +1 -1
- package/dist/eject-theme/components/Banner/index.scss +11 -0
- package/dist/eject-theme/components/Banner/index.tsx +5 -1
- package/dist/eject-theme/components/DocContent/doc.scss +2 -2
- package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -2
- package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -2
- package/dist/eject-theme/components/Link/index.tsx +6 -0
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
- package/dist/eject-theme/components/Nav/hooks.tsx +18 -14
- package/dist/eject-theme/components/Nav/index.tsx +4 -1
- package/dist/eject-theme/components/NavScreen/NavScreenAppearance.tsx +4 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +3 -0
- package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +4 -1
- package/dist/eject-theme/components/Outline/index.tsx +0 -6
- package/dist/eject-theme/components/Search/SearchPanel.tsx +24 -17
- package/dist/eject-theme/components/Search/logic/search.ts +15 -16
- package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
- package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
- package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
- package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
- package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
- package/dist/eject-theme/components/Tag/index.tsx +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +4 -4
- 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.d.ts +4 -2
- package/dist/node/auto-nav-sidebar/walk.js +3 -3
- package/dist/node/constants.d.ts +2 -1
- package/dist/node/constants.js +12 -6
- package/dist/node/initRsbuild.js +21 -19
- package/dist/node/last-updated/index.d.ts +3 -3
- package/dist/node/last-updated/index.js +24 -9
- package/dist/node/mdx/options.js +8 -1
- package/dist/node/mdx/processor.js +3 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.d.ts +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +10 -6
- package/dist/node/mdx/remarkPlugins/link.js +91 -16
- package/dist/node/mdx/remarkPlugins/toc.d.ts +8 -1
- package/dist/node/mdx/remarkPlugins/toc.js +44 -15
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.d.ts +6 -0
- package/dist/node/route/RouteService.js +41 -7
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +7 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -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 +12 -2
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +33 -9
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/htmlFile.d.ts +2 -0
- package/dist/node/ssg/htmlFile.js +14 -0
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.d.ts +3 -6
- package/dist/node/ssg/renderPageWorker.js +24 -4
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +18 -17
- package/dist/node/ssg/rsbuildPluginCSR.js +2 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +6 -4
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- 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 +3 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- 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.d.ts +2 -1
- package/dist/runtime/ClientApp.d.ts +1 -1
- package/dist/runtime/Content.d.ts +1 -1
- package/dist/runtime/NoSSR.d.ts +1 -1
- package/dist/theme/components/Badge/index.d.ts +1 -1
- package/dist/theme/components/Banner/index.css +11 -0
- package/dist/theme/components/Banner/index.js +1 -0
- package/dist/theme/components/CodeBlock/index.d.ts +1 -1
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.d.ts +1 -1
- package/dist/theme/components/CodeButtonGroup/index.d.ts +1 -1
- package/dist/theme/components/DocContent/doc.css +2 -2
- package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/code.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
- package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/pre.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
- package/dist/theme/components/DocContent/index.d.ts +1 -1
- package/dist/theme/components/DocFooter/index.d.ts +1 -1
- package/dist/theme/components/EditLink/index.d.ts +1 -1
- package/dist/theme/components/FallbackHeading/index.d.ts +1 -1
- package/dist/theme/components/HomeBackground/index.d.ts +1 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.d.ts +1 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.js +2 -2
- package/dist/theme/components/HomeFeature/useCardAnimation.d.ts +1 -1
- package/dist/theme/components/HomeFooter/index.d.ts +1 -1
- package/dist/theme/components/HomeHero/index.d.ts +1 -1
- package/dist/theme/components/HoverGroup/index.css +1 -1
- package/dist/theme/components/HoverGroup/index.d.ts +1 -1
- package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.js +13 -3
- package/dist/theme/components/Link/index.js +6 -0
- package/dist/theme/components/Llms/LlmsContainer.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsCopyButton.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsOpenRow.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +1 -1
- package/dist/theme/components/Nav/NavMenu.css +1 -1
- package/dist/theme/components/Nav/NavMenu.d.ts +9 -9
- package/dist/theme/components/Nav/hooks.js +6 -3
- package/dist/theme/components/Nav/index.d.ts +1 -1
- package/dist/theme/components/Nav/index.js +2 -1
- package/dist/theme/components/NavHamburger/index.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenAppearance.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenAppearance.js +2 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenu.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +10 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +5 -5
- package/dist/theme/components/NavScreen/NavScreenMenuOthers.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +2 -1
- package/dist/theme/components/NavScreen/NavScreenVersions.d.ts +1 -1
- package/dist/theme/components/NavScreen/index.d.ts +2 -2
- package/dist/theme/components/NavTitle/index.d.ts +1 -1
- package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -1
- package/dist/theme/components/Outline/index.d.ts +1 -1
- package/dist/theme/components/Outline/index.js +1 -3
- package/dist/theme/components/Overview/index.d.ts +1 -1
- package/dist/theme/components/OverviewGroup/index.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
- package/dist/theme/components/PrevNextPage/index.d.ts +1 -1
- package/dist/theme/components/Prompt/index.d.ts +1 -1
- package/dist/theme/components/ReadPercent/index.d.ts +1 -1
- package/dist/theme/components/Root/index.d.ts +1 -1
- package/dist/theme/components/Search/NoSearchResult.d.ts +1 -1
- package/dist/theme/components/Search/SearchButton.d.ts +1 -1
- package/dist/theme/components/Search/SearchPanel.d.ts +1 -1
- package/dist/theme/components/Search/SearchPanel.js +12 -7
- package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
- package/dist/theme/components/Search/index.d.ts +1 -1
- package/dist/theme/components/Search/logic/search.js +12 -7
- package/dist/theme/components/Sidebar/SidebarDivider.d.ts +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.d.ts +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -2
- package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +1 -1
- package/dist/theme/components/Sidebar/index.d.ts +2 -2
- package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
- package/dist/theme/components/SidebarMenu/index.js +4 -3
- package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +3 -2
- package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
- package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
- package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
- package/dist/theme/components/SocialLinks/SocialLink.d.ts +1 -1
- package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
- package/dist/theme/components/SocialLinks/index.css +19 -0
- package/dist/theme/components/SocialLinks/index.d.ts +1 -1
- package/dist/theme/components/SourceCode/index.d.ts +1 -1
- package/dist/theme/components/Steps/index.d.ts +1 -1
- package/dist/theme/components/SvgWrapper/index.d.ts +1 -1
- package/dist/theme/components/SwitchAppearance/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.js +9 -5
- package/dist/theme/components/Toc/TocItem.d.ts +1 -1
- package/dist/theme/components/Toc/index.d.ts +1 -1
- package/dist/theme/layout/DocLayout/index.d.ts +1 -1
- package/dist/theme/layout/DocLayout/index.js +1 -1
- package/dist/theme/layout/HomeLayout/index.d.ts +1 -1
- package/dist/theme/layout/Layout/index.d.ts +1 -1
- package/dist/theme/layout/NotFountLayout/index.d.ts +1 -1
- package/dist/theme/logic/useThemeState.d.ts +6 -7
- package/dist/theme/logic/useThemeState.js +19 -15
- package/package.json +20 -21
- package/dist/559.js +0 -1
|
@@ -13,18 +13,22 @@ const rehypeHeaderAnchor = ()=>{
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
const collectHeaderText = (node)=>{
|
|
16
|
+
const collectHeaderText = (node, allowCustomId = true)=>{
|
|
17
17
|
let text = '';
|
|
18
18
|
let id = '';
|
|
19
19
|
node.children.forEach((child)=>{
|
|
20
20
|
if ('text' === child.type) {
|
|
21
|
-
const [textPart, idPart] = extractTextAndId(child.value)
|
|
21
|
+
const [textPart, idPart] = allowCustomId ? extractTextAndId(child.value) : [
|
|
22
|
+
child.value,
|
|
23
|
+
''
|
|
24
|
+
];
|
|
22
25
|
child.value = textPart;
|
|
23
26
|
text += textPart;
|
|
24
|
-
id = idPart;
|
|
25
|
-
} else if ('element' === child.type)
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
if (idPart) id = idPart;
|
|
28
|
+
} else if ('element' === child.type) {
|
|
29
|
+
const [childText] = collectHeaderText(child, false);
|
|
30
|
+
text += childText;
|
|
31
|
+
}
|
|
28
32
|
});
|
|
29
33
|
return [
|
|
30
34
|
text,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../../0~rslib-runtime.js";
|
|
2
2
|
import "../../../7986.js";
|
|
3
|
-
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3358.js";
|
|
3
|
+
import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, MDX_OR_MD_REGEXP, withBase } from "../../../3358.js";
|
|
4
4
|
import { hintRelativeMarkdownLink } from "../../logger/hint.js";
|
|
5
5
|
import { createError } from "../../utils/error.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
7
7
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
|
|
8
|
+
function createExcluder(checkOption) {
|
|
9
|
+
const excludes = 'object' == typeof checkOption ? checkOption.excludes : void 0;
|
|
11
10
|
const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
|
|
12
11
|
const excludesFn = 'function' == typeof excludes ? excludes : void 0;
|
|
12
|
+
return (url)=>Boolean(excludesUrl?.has(url) || excludesFn?.(url));
|
|
13
|
+
}
|
|
14
|
+
function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
|
|
15
|
+
const errorInfos = [];
|
|
16
|
+
const isExcluded = createExcluder(checkDeadLinks);
|
|
13
17
|
let possibleBreakingChange = false;
|
|
14
18
|
[
|
|
15
19
|
...internalLinks.entries()
|
|
16
20
|
].forEach(([nodeUrl, link])=>{
|
|
17
|
-
if (
|
|
18
|
-
if (excludesFn?.(nodeUrl)) return;
|
|
21
|
+
if (isExcluded(nodeUrl)) return;
|
|
19
22
|
if (!nodeUrl.startsWith('/') && /^\w/.test(nodeUrl)) possibleBreakingChange = true;
|
|
20
23
|
errorInfos.push([
|
|
21
24
|
nodeUrl,
|
|
@@ -33,6 +36,52 @@ ${errorInfos.map(([nodeUrl, link])=>` ${picocolors_default().green(`"[..](${nod
|
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
function checkDeadAnchors(checkAnchors, anchorLinks, routeService, file, lint) {
|
|
40
|
+
const errorInfos = [];
|
|
41
|
+
const isExcluded = createExcluder(checkAnchors);
|
|
42
|
+
[
|
|
43
|
+
...anchorLinks.entries()
|
|
44
|
+
].forEach(([nodeUrl, link])=>{
|
|
45
|
+
if (isExcluded(nodeUrl) || !link.hash || !link.routePath) return;
|
|
46
|
+
const routePage = routeService.getRoutePageByRouteLink(link.routePath);
|
|
47
|
+
if (!routePage) return;
|
|
48
|
+
if (!MDX_OR_MD_REGEXP.test(routePage.routeMeta.absolutePath)) return;
|
|
49
|
+
const anchorIds = routeService.getRouteAnchorIds(link.routePath);
|
|
50
|
+
if (anchorIds) return void collectDeadAnchor(errorInfos, anchorIds, nodeUrl, link);
|
|
51
|
+
routeService.onRouteAnchorIds(link.routePath, (targetAnchorIds)=>{
|
|
52
|
+
const deferredErrorInfos = [];
|
|
53
|
+
collectDeadAnchor(deferredErrorInfos, targetAnchorIds, nodeUrl, link);
|
|
54
|
+
reportDeadAnchors(deferredErrorInfos, file, lint);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
reportDeadAnchors(errorInfos, file, lint);
|
|
58
|
+
}
|
|
59
|
+
function collectDeadAnchor(errorInfos, anchorIds, nodeUrl, link) {
|
|
60
|
+
if (!link.hash || !link.routePath) return;
|
|
61
|
+
const hash = decodeHash(link.hash);
|
|
62
|
+
if (!anchorIds.has(hash)) errorInfos.push([
|
|
63
|
+
nodeUrl,
|
|
64
|
+
`${link.routePath}#${link.hash}`
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
function reportDeadAnchors(errorInfos, file, lint) {
|
|
68
|
+
if (errorInfos.length > 0) {
|
|
69
|
+
const message = `Dead anchors found${lint ? '' : ` in ${picocolors_default().cyan(file.path)}`}:
|
|
70
|
+
${errorInfos.map(([nodeUrl, link])=>` ${picocolors_default().green(`"[..](${nodeUrl})"`)} ${picocolors_default().gray(link)}`).join('\n')}`;
|
|
71
|
+
if (lint) file.message(message);
|
|
72
|
+
else {
|
|
73
|
+
logger.error(message);
|
|
74
|
+
if (isProduction()) throw createError('Dead anchor found');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function decodeHash(hash) {
|
|
79
|
+
try {
|
|
80
|
+
return decodeURIComponent(hash);
|
|
81
|
+
} catch {
|
|
82
|
+
return hash;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
36
85
|
function looseMarkdownLink(url, routeService, filePath) {
|
|
37
86
|
if (!routeService.isInDocsDir(filePath)) return url;
|
|
38
87
|
const [versionPart, langPart, pureRoute] = routeService.splitRoutePathParts(url);
|
|
@@ -51,10 +100,23 @@ function looseMarkdownLink(url, routeService, filePath) {
|
|
|
51
100
|
return url;
|
|
52
101
|
}
|
|
53
102
|
function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, deadLinks, __base) {
|
|
54
|
-
if (!nodeUrl) return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
103
|
+
if (!nodeUrl) return {
|
|
104
|
+
url: ''
|
|
105
|
+
};
|
|
106
|
+
if (nodeUrl.startsWith('#')) {
|
|
107
|
+
const routePath = routeService?.getRoutePageByFilePath(filePath)?.routeMeta.routePath;
|
|
108
|
+
return {
|
|
109
|
+
url: nodeUrl,
|
|
110
|
+
routePath,
|
|
111
|
+
hash: nodeUrl.slice(1)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (isExternalUrl(nodeUrl)) return {
|
|
115
|
+
url: nodeUrl
|
|
116
|
+
};
|
|
117
|
+
if (!routeService) return {
|
|
118
|
+
url: nodeUrl
|
|
119
|
+
};
|
|
58
120
|
let { url, hash, search } = parseUrl(nodeUrl);
|
|
59
121
|
if (url.startsWith('/')) {
|
|
60
122
|
if (autoPrefix) url = looseMarkdownLink(url, routeService, filePath);
|
|
@@ -68,34 +130,47 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
68
130
|
url = normalizeHref(url, cleanUrls);
|
|
69
131
|
if (!routeService.isExistRoute(url)) {
|
|
70
132
|
deadLinks.set(nodeUrl, url);
|
|
71
|
-
return
|
|
133
|
+
return {
|
|
134
|
+
url: nodeUrl
|
|
135
|
+
};
|
|
72
136
|
}
|
|
73
137
|
} else {
|
|
74
138
|
url = normalizeHref(url, false);
|
|
75
139
|
if (!routeService.isExistRoute(url)) {
|
|
76
140
|
deadLinks.set(nodeUrl, url);
|
|
77
|
-
return
|
|
141
|
+
return {
|
|
142
|
+
url: nodeUrl
|
|
143
|
+
};
|
|
78
144
|
}
|
|
79
145
|
url = url.replace(/\.html$/, cleanUrls);
|
|
80
146
|
}
|
|
147
|
+
const routePath = url;
|
|
81
148
|
if (search) url += `?${search}`;
|
|
82
149
|
if (hash) url += `#${hash}`;
|
|
83
150
|
if (__base) url = withBase(url, __base);
|
|
84
|
-
return
|
|
151
|
+
return {
|
|
152
|
+
url,
|
|
153
|
+
routePath,
|
|
154
|
+
hash
|
|
155
|
+
};
|
|
85
156
|
}
|
|
86
157
|
const remarkLink = ({ cleanUrls, routeService, remarkLinkOptions, lint, __base })=>(tree, file)=>{
|
|
87
|
-
const { checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
158
|
+
const { checkAnchors: shouldCheckAnchors = false, checkDeadLinks: shouldCheckDeadLinks = true, autoPrefix = true } = remarkLinkOptions ?? {};
|
|
88
159
|
const deadLinks = new Map();
|
|
160
|
+
const anchorLinks = new Map();
|
|
89
161
|
visit(tree, 'link', (node)=>{
|
|
90
162
|
const { url: nodeUrl } = node;
|
|
91
163
|
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
92
|
-
|
|
164
|
+
if (link.hash) anchorLinks.set(nodeUrl, link);
|
|
165
|
+
node.url = link.url;
|
|
93
166
|
});
|
|
94
167
|
visit(tree, 'definition', (node)=>{
|
|
95
168
|
const { url: nodeUrl } = node;
|
|
96
169
|
const link = normalizeLink(nodeUrl, routeService, file.path, cleanUrls, autoPrefix, deadLinks, __base);
|
|
97
|
-
|
|
170
|
+
if (link.hash) anchorLinks.set(nodeUrl, link);
|
|
171
|
+
node.url = link.url;
|
|
98
172
|
});
|
|
99
173
|
if (shouldCheckDeadLinks && routeService) link_checkDeadLinks(shouldCheckDeadLinks, deadLinks, file, lint);
|
|
174
|
+
if (shouldCheckAnchors && routeService) checkDeadAnchors(shouldCheckAnchors, anchorLinks, routeService, file, lint);
|
|
100
175
|
};
|
|
101
176
|
export { remarkLink };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Root as HastRoot } from 'hast';
|
|
2
2
|
import type { Root as MdastRoot } from 'mdast';
|
|
3
3
|
import type { Plugin } from 'unified';
|
|
4
|
+
import type { RouteService } from '../../route/RouteService.js';
|
|
4
5
|
export interface TocItem {
|
|
5
6
|
id: string;
|
|
6
7
|
text: string;
|
|
@@ -9,5 +10,11 @@ export interface TocItem {
|
|
|
9
10
|
export declare const parseToc: (tree: MdastRoot | HastRoot) => {
|
|
10
11
|
title: string;
|
|
11
12
|
toc: TocItem[];
|
|
13
|
+
anchorIds: string[];
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
interface RemarkTocOptions {
|
|
16
|
+
routeService?: RouteService | null;
|
|
17
|
+
fallbackHeadingTitle?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const remarkToc: Plugin<[RemarkTocOptions?], HastRoot>;
|
|
20
|
+
export {};
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const extractChildText = (child)=>{
|
|
3
|
-
if ('link' === child.type) return child.children?.map(extractChildText).join('') ?? '';
|
|
4
|
-
if ('strong' === child.type)
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { visitChildren, extractTextAndId, github_slugger, slug } from "../../../8005.js";
|
|
2
|
+
const extractChildText = (child, preserveInlineMarkdown = true)=>{
|
|
3
|
+
if ('link' === child.type) return child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
|
|
4
|
+
if ('strong' === child.type) {
|
|
5
|
+
const text = child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
|
|
6
|
+
return preserveInlineMarkdown ? `**${text}**` : text;
|
|
7
|
+
}
|
|
8
|
+
if ('emphasis' === child.type) {
|
|
9
|
+
const text = child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
|
|
10
|
+
return preserveInlineMarkdown ? `*${text}*` : text;
|
|
11
|
+
}
|
|
12
|
+
if ('delete' === child.type) {
|
|
13
|
+
const text = child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
|
|
14
|
+
return preserveInlineMarkdown ? `~~${text}~~` : text;
|
|
15
|
+
}
|
|
7
16
|
if ('text' === child.type) return child.value;
|
|
8
|
-
if ('inlineCode' === child.type) return `\`${child.value}
|
|
17
|
+
if ('inlineCode' === child.type) return preserveInlineMarkdown ? `\`${child.value}\`` : child.value;
|
|
9
18
|
return '';
|
|
10
19
|
};
|
|
11
20
|
const parseToc = (tree)=>{
|
|
12
21
|
let title = '';
|
|
13
22
|
const toc = [];
|
|
23
|
+
const anchorIds = [];
|
|
14
24
|
const slugger = new github_slugger();
|
|
15
25
|
visitChildren((node)=>{
|
|
16
26
|
if ('heading' !== node.type || !node.depth || !node.children) return;
|
|
17
|
-
if (node.depth >= 1 && node.depth
|
|
27
|
+
if (node.depth >= 1 && node.depth <= 6) {
|
|
18
28
|
let customId = '';
|
|
19
29
|
const text = node.children.map((child)=>{
|
|
20
30
|
if ('text' === child.type) {
|
|
@@ -24,10 +34,18 @@ const parseToc = (tree)=>{
|
|
|
24
34
|
}
|
|
25
35
|
return extractChildText(child);
|
|
26
36
|
}).join('').trim();
|
|
37
|
+
const titleText = node.children.map((child)=>{
|
|
38
|
+
if ('text' === child.type) {
|
|
39
|
+
const [textPart] = extractTextAndId(child.value);
|
|
40
|
+
return textPart;
|
|
41
|
+
}
|
|
42
|
+
return extractChildText(child, false);
|
|
43
|
+
}).join('').trim();
|
|
44
|
+
const id = customId ? customId : slugger.slug(text);
|
|
45
|
+
anchorIds.push(id);
|
|
27
46
|
if (1 === node.depth) {
|
|
28
|
-
if (!title) title =
|
|
29
|
-
} else {
|
|
30
|
-
const id = customId ? customId : slugger.slug(text);
|
|
47
|
+
if (!title) title = titleText;
|
|
48
|
+
} else if (node.depth < 5) {
|
|
31
49
|
const { depth } = node;
|
|
32
50
|
toc.push({
|
|
33
51
|
id,
|
|
@@ -39,15 +57,26 @@ const parseToc = (tree)=>{
|
|
|
39
57
|
})(tree);
|
|
40
58
|
return {
|
|
41
59
|
title,
|
|
42
|
-
toc
|
|
60
|
+
toc,
|
|
61
|
+
anchorIds
|
|
43
62
|
};
|
|
44
63
|
};
|
|
45
|
-
const remarkToc = function() {
|
|
64
|
+
const remarkToc = function(options = {}) {
|
|
46
65
|
const data = this.data();
|
|
47
|
-
return (tree)=>{
|
|
48
|
-
const { toc, title } = parseToc(tree);
|
|
66
|
+
return (tree, file)=>{
|
|
67
|
+
const { toc, title, anchorIds } = parseToc(tree);
|
|
49
68
|
data.pageMeta.toc = toc;
|
|
50
69
|
if (title) data.pageMeta.title = title;
|
|
70
|
+
if (file.path) {
|
|
71
|
+
const registeredAnchorIds = new Set(anchorIds);
|
|
72
|
+
const fallbackHeadingTitle = data.pageMeta.frontmatter?.title;
|
|
73
|
+
if (!title && false !== options.fallbackHeadingTitle && 'string' == typeof fallbackHeadingTitle) {
|
|
74
|
+
const [fallbackHeadingText] = extractTextAndId(fallbackHeadingTitle);
|
|
75
|
+
const fallbackHeadingAnchorId = slug(fallbackHeadingText.trim());
|
|
76
|
+
if (fallbackHeadingAnchorId) registeredAnchorIds.add(fallbackHeadingAnchorId);
|
|
77
|
+
}
|
|
78
|
+
options.routeService?.setRouteAnchorIds(file.path, registeredAnchorIds);
|
|
79
|
+
}
|
|
51
80
|
};
|
|
52
81
|
};
|
|
53
82
|
export { parseToc, remarkToc };
|
|
@@ -6,6 +6,7 @@ interface InitOptions {
|
|
|
6
6
|
config: UserConfig;
|
|
7
7
|
externalPages: AdditionalPage[];
|
|
8
8
|
}
|
|
9
|
+
type RouteAnchorIdsConsumer = (anchorIds: Set<string>) => void;
|
|
9
10
|
export interface Route {
|
|
10
11
|
path: string;
|
|
11
12
|
element: React.ReactElement;
|
|
@@ -31,6 +32,11 @@ export declare class RouteService {
|
|
|
31
32
|
getRoutes(): RouteMeta[];
|
|
32
33
|
getRoutePages(): RoutePage[];
|
|
33
34
|
isExistRoute(link: string): boolean;
|
|
35
|
+
getRoutePageByRouteLink(link: string): RoutePage | undefined;
|
|
36
|
+
getRoutePageByFilePath(filePath: string): RoutePage | undefined;
|
|
37
|
+
setRouteAnchorIds(filePath: string, anchorIds: Set<string>): void;
|
|
38
|
+
getRouteAnchorIds(routeLink: string): Set<string> | undefined;
|
|
39
|
+
onRouteAnchorIds(routeLink: string, consumer: RouteAnchorIdsConsumer): void;
|
|
34
40
|
generateRoutesCode(): string;
|
|
35
41
|
private generateRoutesCodeByRouteMeta;
|
|
36
42
|
getRoutePathParts(relativePath: string): string[];
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../
|
|
1
|
+
import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../6010.js";
|
|
2
2
|
import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
|
|
3
3
|
import { createError } from "../utils/error.js";
|
|
4
4
|
import { getRoutePathParts, normalizeRoutePath, splitRoutePathParts } from "./normalizeRoutePath.js";
|
|
5
5
|
class RouteService {
|
|
6
6
|
routeData = new Map();
|
|
7
|
+
#routeDataByFilePath = new Map();
|
|
8
|
+
#routeAnchorIds = new Map();
|
|
9
|
+
#routeAnchorIdsConsumers = new Map();
|
|
7
10
|
#scanDir;
|
|
8
11
|
#defaultLang;
|
|
9
12
|
#defaultVersion;
|
|
@@ -99,6 +102,7 @@ class RouteService {
|
|
|
99
102
|
const { routeMeta: { routePath } } = routePage;
|
|
100
103
|
if (this.routeData.has(routePath)) throw createError(`routePath ${routePath} has already been added`);
|
|
101
104
|
this.routeData.set(routePath, routePage);
|
|
105
|
+
this.#routeDataByFilePath.set(node_path.normalize(routePage.routeMeta.absolutePath), routePage);
|
|
102
106
|
}
|
|
103
107
|
getRoutes() {
|
|
104
108
|
return Array.from(this.routeData.values()).map((i)=>i.routeMeta);
|
|
@@ -107,12 +111,39 @@ class RouteService {
|
|
|
107
111
|
return Array.from(this.routeData.values());
|
|
108
112
|
}
|
|
109
113
|
isExistRoute(link) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const cleanLinkPath = linkToRoutePath(link);
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
return Boolean(this.getRoutePageByRouteLink(link));
|
|
115
|
+
}
|
|
116
|
+
getRoutePageByRouteLink(link) {
|
|
117
|
+
const cleanLinkPath = this.#linkToRoutePath(link);
|
|
118
|
+
return this.routeData.get(removeTrailingSlash(cleanLinkPath)) ?? this.routeData.get(addTrailingSlash(cleanLinkPath));
|
|
119
|
+
}
|
|
120
|
+
getRoutePageByFilePath(filePath) {
|
|
121
|
+
return this.#routeDataByFilePath.get(node_path.normalize(filePath));
|
|
122
|
+
}
|
|
123
|
+
setRouteAnchorIds(filePath, anchorIds) {
|
|
124
|
+
const routePage = this.getRoutePageByFilePath(filePath);
|
|
125
|
+
if (!routePage) return;
|
|
126
|
+
const { routePath } = routePage.routeMeta;
|
|
127
|
+
this.#routeAnchorIds.set(routePath, anchorIds);
|
|
128
|
+
const consumers = this.#routeAnchorIdsConsumers.get(routePath);
|
|
129
|
+
if (!consumers) return;
|
|
130
|
+
this.#routeAnchorIdsConsumers.delete(routePath);
|
|
131
|
+
for (const consumer of consumers)consumer(anchorIds);
|
|
132
|
+
}
|
|
133
|
+
getRouteAnchorIds(routeLink) {
|
|
134
|
+
const routePage = this.getRoutePageByRouteLink(routeLink);
|
|
135
|
+
if (!routePage) return;
|
|
136
|
+
return this.#routeAnchorIds.get(routePage.routeMeta.routePath);
|
|
137
|
+
}
|
|
138
|
+
onRouteAnchorIds(routeLink, consumer) {
|
|
139
|
+
const routePage = this.getRoutePageByRouteLink(routeLink);
|
|
140
|
+
if (!routePage) return;
|
|
141
|
+
const { routePath } = routePage.routeMeta;
|
|
142
|
+
const anchorIds = this.#routeAnchorIds.get(routePath);
|
|
143
|
+
if (anchorIds) return void consumer(anchorIds);
|
|
144
|
+
const consumers = this.#routeAnchorIdsConsumers.get(routePath) ?? [];
|
|
145
|
+
consumers.push(consumer);
|
|
146
|
+
this.#routeAnchorIdsConsumers.set(routePath, consumers);
|
|
116
147
|
}
|
|
117
148
|
generateRoutesCode() {
|
|
118
149
|
return this.generateRoutesCodeByRouteMeta(this.getRoutes());
|
|
@@ -158,6 +189,9 @@ ${routeMeta.map((route, index)=>{
|
|
|
158
189
|
await promises.writeFile(tempFilePath, content);
|
|
159
190
|
return tempFilePath;
|
|
160
191
|
}
|
|
192
|
+
#linkToRoutePath(routePath) {
|
|
193
|
+
return decodeURIComponent(routePath.split('#')[0]).replace(/\.html$/, '').replace(/\/index$/, '/');
|
|
194
|
+
}
|
|
161
195
|
getRoutePageByRoutePath(routePath) {
|
|
162
196
|
return this.routeData.get(routePath);
|
|
163
197
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../
|
|
1
|
+
import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../6010.js";
|
|
2
2
|
import { applyReplaceRules } from "../utils/applyReplaceRules.js";
|
|
3
3
|
import { flattenMdxContent } from "../utils/flattenMdxContent.js";
|
|
4
4
|
import { importStatementRegex } from "../constants.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../
|
|
1
|
+
import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../6010.js";
|
|
2
2
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
3
3
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
4
4
|
return [
|
|
@@ -48,6 +48,13 @@ export declare const DEFAULT_I18N_TEXT: {
|
|
|
48
48
|
readonly ko: '업데이트 날짜';
|
|
49
49
|
readonly ru: 'Последнее обновление';
|
|
50
50
|
};
|
|
51
|
+
readonly lastUpdatedAuthorText: {
|
|
52
|
+
readonly en: 'by';
|
|
53
|
+
readonly zh: '作者';
|
|
54
|
+
readonly ja: '更新者';
|
|
55
|
+
readonly ko: '작성자';
|
|
56
|
+
readonly ru: 'автор';
|
|
57
|
+
};
|
|
51
58
|
readonly prevPageText: {
|
|
52
59
|
readonly en: 'Previous page';
|
|
53
60
|
readonly zh: '上一页';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../7986.js";
|
|
3
|
-
import { external_node_module_createRequire, join, logger } from "../../
|
|
3
|
+
import { external_node_module_createRequire, join, logger } from "../../6010.js";
|
|
4
4
|
import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
|
|
5
5
|
import { createError } from "../utils/error.js";
|
|
6
6
|
import { pathExists } from "../utils/fs.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SEARCH_INDEX_NAME, groupBy } from "../../../
|
|
1
|
+
import { SEARCH_INDEX_NAME, groupBy } from "../../../6010.js";
|
|
2
2
|
import { extractPageData } from "../../route/extractPageData.js";
|
|
3
3
|
import { createHash } from "../../utils/createHash.js";
|
|
4
4
|
function deletePrivateField(obj) {
|
|
@@ -30,6 +30,7 @@ async function createPageData(context) {
|
|
|
30
30
|
const versioned = 'boolean' != typeof userConfig.search && (userConfig.search?.versioned ?? true);
|
|
31
31
|
const groupedPages = groupBy(pages, (page)=>{
|
|
32
32
|
if (page.frontmatter?.pageType === 'home') return 'noindex';
|
|
33
|
+
if (page.frontmatter?.search === false) return 'noindex';
|
|
33
34
|
const version = versioned ? page.version : '';
|
|
34
35
|
const lang = page.lang || '';
|
|
35
36
|
return `${version}###${lang}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, pluginVirtualModule } from "../../../
|
|
1
|
+
import { logger, pluginVirtualModule } from "../../../6010.js";
|
|
2
2
|
import { createPageData } from "./createPageData.js";
|
|
3
3
|
const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
|
|
4
4
|
const ref = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getIconUrlPath } from "../../../
|
|
1
|
+
import { getIconUrlPath } from "../../../6010.js";
|
|
2
2
|
import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
|
|
3
3
|
async function createSiteData(userConfig) {
|
|
4
4
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../
|
|
1
|
+
import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../6010.js";
|
|
2
2
|
import { getI18nData } from "../i18n.js";
|
|
3
3
|
import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
|
|
4
4
|
async function normalizeThemeConfig(docConfig) {
|
|
@@ -21,6 +21,13 @@ async function normalizeThemeConfig(docConfig) {
|
|
|
21
21
|
const cleanUrls = false;
|
|
22
22
|
const transformLink = (link, currentLang)=>normalizeHref(normalizeLinkPrefix(link, currentLang), cleanUrls);
|
|
23
23
|
const textReplace = (text, currentLang)=>applyReplaceRules(getI18nText(text, currentLang), replaceRules);
|
|
24
|
+
const normalizeLastUpdated = (lastUpdated)=>{
|
|
25
|
+
if ('object' != typeof lastUpdated || null === lastUpdated) return lastUpdated;
|
|
26
|
+
return {
|
|
27
|
+
...lastUpdated,
|
|
28
|
+
author: 'function' == typeof lastUpdated.author ? true : lastUpdated.author
|
|
29
|
+
};
|
|
30
|
+
};
|
|
24
31
|
const normalizeSidebar = (sidebar, currentLang)=>{
|
|
25
32
|
const normalizedSidebar = {};
|
|
26
33
|
if (!sidebar) return {};
|
|
@@ -89,6 +96,9 @@ async function normalizeThemeConfig(docConfig) {
|
|
|
89
96
|
themeConfig.sidebar = normalizeSidebar(themeConfig?.sidebar, '');
|
|
90
97
|
themeConfig.nav = normalizeNav(themeConfig?.nav, '');
|
|
91
98
|
}
|
|
92
|
-
return
|
|
99
|
+
return {
|
|
100
|
+
...themeConfig,
|
|
101
|
+
lastUpdated: normalizeLastUpdated(themeConfig.lastUpdated)
|
|
102
|
+
};
|
|
93
103
|
}
|
|
94
104
|
export { normalizeThemeConfig };
|
|
@@ -1,23 +1,47 @@
|
|
|
1
|
-
import { logger } from "../../../
|
|
1
|
+
import { isProduction, logger } from "../../../6010.js";
|
|
2
2
|
import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
|
|
3
3
|
import { createSiteData } from "./createSiteData.js";
|
|
4
4
|
const siteDataVMPlugin = (context)=>{
|
|
5
5
|
const { config, pluginDriver } = context;
|
|
6
|
+
let siteDataModulePromise;
|
|
7
|
+
const createSiteDataModule = async (metaFileSet = new Set(), mdFileSet = new Set())=>{
|
|
8
|
+
const force = !pluginDriver.haveNavSidebarConfig;
|
|
9
|
+
const now = performance.now();
|
|
10
|
+
try {
|
|
11
|
+
await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
|
|
12
|
+
} finally{
|
|
13
|
+
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
14
|
+
}
|
|
15
|
+
const { siteData } = await createSiteData(config);
|
|
16
|
+
return {
|
|
17
|
+
code: `export default ${JSON.stringify(siteData, null, 2)}`,
|
|
18
|
+
metaFileSet,
|
|
19
|
+
mdFileSet
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getSiteDataModule = (metaFileSet, mdFileSet)=>{
|
|
23
|
+
if (!isProduction()) return createSiteDataModule(metaFileSet, mdFileSet);
|
|
24
|
+
siteDataModulePromise ??= createSiteDataModule(metaFileSet, mdFileSet).catch((error)=>{
|
|
25
|
+
siteDataModulePromise = void 0;
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
return siteDataModulePromise;
|
|
29
|
+
};
|
|
30
|
+
const addSiteDataDependencies = (addDependency, metaFileSet, mdFileSet)=>{
|
|
31
|
+
for (const metaFile of metaFileSet)addDependency(metaFile);
|
|
32
|
+
for (const mdFile of mdFileSet)addDependency(mdFile);
|
|
33
|
+
};
|
|
6
34
|
return {
|
|
7
35
|
["virtual-site-data"]: async ({ addDependency })=>{
|
|
8
|
-
const force = !pluginDriver.haveNavSidebarConfig;
|
|
9
36
|
const metaFileSet = new Set();
|
|
10
37
|
const mdFileSet = new Set();
|
|
11
|
-
|
|
38
|
+
let siteDataModule;
|
|
12
39
|
try {
|
|
13
|
-
await
|
|
40
|
+
siteDataModule = await getSiteDataModule(metaFileSet, mdFileSet);
|
|
41
|
+
return siteDataModule.code;
|
|
14
42
|
} finally{
|
|
15
|
-
|
|
16
|
-
for (const mdFile of mdFileSet)addDependency(mdFile);
|
|
17
|
-
logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
|
|
43
|
+
addSiteDataDependencies(addDependency, siteDataModule?.metaFileSet ?? metaFileSet, siteDataModule?.mdFileSet ?? mdFileSet);
|
|
18
44
|
}
|
|
19
|
-
const { siteData } = await createSiteData(config);
|
|
20
|
-
return `export default ${JSON.stringify(siteData, null, 2)}`;
|
|
21
45
|
}
|
|
22
46
|
};
|
|
23
47
|
};
|
package/dist/node/serve.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { external_node_path_resolve, relative, isAbsolute } from "../../9958.js";
|
|
2
|
+
const routePath2HtmlFileName = (routePath)=>{
|
|
3
|
+
let fileName = routePath;
|
|
4
|
+
fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
|
|
5
|
+
return fileName.replace(/^\/+/, '');
|
|
6
|
+
};
|
|
7
|
+
function resolveHtmlFilePath(distPath, routePath) {
|
|
8
|
+
const distPathAbsolute = external_node_path_resolve(distPath);
|
|
9
|
+
const fileAbsolutePath = external_node_path_resolve(distPathAbsolute, routePath2HtmlFileName(routePath));
|
|
10
|
+
const relativePath = relative(distPathAbsolute, fileAbsolutePath);
|
|
11
|
+
if (relativePath.startsWith('..') || isAbsolute(relativePath)) throw new Error(`SSG route path "${routePath}" resolves outside of the output directory.`);
|
|
12
|
+
return fileAbsolutePath;
|
|
13
|
+
}
|
|
14
|
+
export { resolveHtmlFilePath, routePath2HtmlFileName };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../7986.js";
|
|
3
|
-
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../
|
|
3
|
+
import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../9958.js";
|
|
4
4
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
5
5
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
6
6
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { RouteMeta
|
|
2
|
-
interface
|
|
1
|
+
import type { RouteMeta } from '@rspress/shared';
|
|
2
|
+
interface WorkerTask {
|
|
3
3
|
routes: RouteMeta[];
|
|
4
|
-
htmlTemplate: string;
|
|
5
|
-
head: UserConfig['head'];
|
|
6
|
-
ssrBundlePath: string;
|
|
7
4
|
}
|
|
8
|
-
declare const exportWorkerGlueFn: ({ routes }:
|
|
5
|
+
declare const exportWorkerGlueFn: ({ routes, }: WorkerTask) => Promise<string[]>;
|
|
9
6
|
export default exportWorkerGlueFn;
|