@rspress/core 2.0.14 → 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/3358.js +1 -1
- package/dist/5580.js +1 -1
- package/dist/{4942.js → 6010.js} +1 -1
- package/dist/8005.js +1 -1
- package/dist/{7261.js → 9958.js} +2 -1
- package/dist/cli/index.js +1 -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/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/Search/SearchPanel.tsx +23 -17
- 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 +8 -15
- 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 +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/htmlFile.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/rsbuildPluginCSR.js +2 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +5 -3
- 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/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/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/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 +11 -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/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/useSidebarMenu.d.ts +1 -1
- package/dist/theme/components/SocialLinks/GithubStars.d.ts +1 -1
- package/dist/theme/components/SocialLinks/SocialLink.d.ts +1 -1
- 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/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/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 +17 -17
package/dist/0~execa.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
|
8
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
10
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
11
|
-
import "./
|
|
11
|
+
import "./6010.js";
|
|
12
12
|
__webpack_require__.add({
|
|
13
13
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
14
|
const cp = __webpack_require__("child_process");
|
package/dist/3358.js
CHANGED
|
@@ -4,5 +4,5 @@ export { cwd } from "node:process";
|
|
|
4
4
|
export { logger } from "@rspress/shared/logger";
|
|
5
5
|
export { visit } from "unist-util-visit";
|
|
6
6
|
export { existsSync } from "node:fs";
|
|
7
|
-
export { addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
7
|
+
export { MDX_OR_MD_REGEXP, addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
8
8
|
export { getNodeAttribute } from "@rspress/shared/node-utils";
|
package/dist/5580.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! LICENSE: 5580.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
-
import "./
|
|
3
|
+
import "./6010.js";
|
|
4
4
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
5
5
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
6
6
|
__webpack_require__.add({
|
package/dist/{4942.js → 6010.js}
RENAMED
|
@@ -2439,7 +2439,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
2439
2439
|
});
|
|
2440
2440
|
export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
2441
2441
|
export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
2442
|
-
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2442
|
+
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeDarkMode, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2443
2443
|
export { logger } from "@rspress/shared/logger";
|
|
2444
2444
|
export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2445
2445
|
export { createRequire as external_node_module_createRequire } from "node:module";
|
package/dist/8005.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as node_os } from "node:os";
|
|
2
2
|
export { default as node_path } from "node:path";
|
|
3
|
-
export { default as github_slugger } from "@rspress/shared/github-slugger";
|
|
3
|
+
export { default as github_slugger, slug } from "@rspress/shared/github-slugger";
|
|
4
4
|
export { extractTextAndId } from "@rspress/shared/node-utils";
|
|
5
5
|
export { visitChildren } from "unist-util-visit-children";
|
package/dist/{7261.js → 9958.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var package_namespaceObject = {
|
|
2
|
-
rE: "2.0.
|
|
2
|
+
rE: "2.0.15"
|
|
3
3
|
};
|
|
4
4
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
5
5
|
return new Promise((resolve_, reject_)=>{
|
|
@@ -92,6 +92,7 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
const pMapSkip = Symbol('skip');
|
|
95
|
+
export { getDefaultDarkModeValue, isDarkModeSwitchEnabled } from "@rspress/shared";
|
|
95
96
|
export { createRequire } from "node:module";
|
|
96
97
|
export { default as node_path, isAbsolute, relative, resolve as external_node_path_resolve } from "node:path";
|
|
97
98
|
export { pathToFileURL } from "node:url";
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../0~rslib-runtime.js";
|
|
2
2
|
import { node_path, logger, join, cac } from "../5580.js";
|
|
3
3
|
import "../7986.js";
|
|
4
|
-
import { package_namespaceObject } from "../
|
|
4
|
+
import { package_namespaceObject } from "../9958.js";
|
|
5
5
|
import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
|
|
6
6
|
import { dev } from "../node/dev.js";
|
|
7
7
|
import { build } from "../node/build.js";
|
|
@@ -259,11 +259,11 @@
|
|
|
259
259
|
color: var(--rp-c-text-code);
|
|
260
260
|
}
|
|
261
261
|
&:where(a > code) {
|
|
262
|
-
color: var(--rp-c-
|
|
262
|
+
color: var(--rp-c-link);
|
|
263
263
|
transition: color 0.25s;
|
|
264
264
|
}
|
|
265
265
|
&:where(a:hover > code) {
|
|
266
|
-
color: var(--rp-c-
|
|
266
|
+
color: var(--rp-c-link);
|
|
267
267
|
}
|
|
268
268
|
// #endregion
|
|
269
269
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
const useTopArrived = () => {
|
|
4
4
|
const [scrollY, setScrollY] = useState(0);
|
|
@@ -26,7 +26,7 @@ const useTopArrived = () => {
|
|
|
26
26
|
export const useNavTransparent = () => {
|
|
27
27
|
const { topArrived } = useTopArrived();
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
30
|
if (topArrived) {
|
|
31
31
|
document.body.classList.remove('notTopArrived');
|
|
32
32
|
} else {
|
|
@@ -3,7 +3,7 @@ import './index.scss';
|
|
|
3
3
|
|
|
4
4
|
export function LastUpdated() {
|
|
5
5
|
const {
|
|
6
|
-
page: { lastUpdatedTime },
|
|
6
|
+
page: { lastUpdatedTime, lastUpdatedAuthor },
|
|
7
7
|
} = usePage();
|
|
8
8
|
const { site } = useSite();
|
|
9
9
|
const { themeConfig } = site;
|
|
@@ -11,7 +11,7 @@ export function LastUpdated() {
|
|
|
11
11
|
|
|
12
12
|
const t = useI18n();
|
|
13
13
|
|
|
14
|
-
if (!showLastUpdated) {
|
|
14
|
+
if (!showLastUpdated || !lastUpdatedTime) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,6 +19,12 @@ export function LastUpdated() {
|
|
|
19
19
|
<div className="rp-last-updated">
|
|
20
20
|
<p>
|
|
21
21
|
{t('lastUpdatedText')}: <span>{lastUpdatedTime}</span>
|
|
22
|
+
{lastUpdatedAuthor && (
|
|
23
|
+
<>
|
|
24
|
+
{' '}
|
|
25
|
+
{t('lastUpdatedAuthorText')} <span>{lastUpdatedAuthor}</span>
|
|
26
|
+
</>
|
|
27
|
+
)}
|
|
22
28
|
</p>
|
|
23
29
|
</div>
|
|
24
30
|
);
|
|
@@ -79,22 +79,26 @@ export function useLangsMenu() {
|
|
|
79
79
|
const translationMenuData = hasMultiLanguage
|
|
80
80
|
? {
|
|
81
81
|
items: localeLanguages.map(item => {
|
|
82
|
+
const isCurrentLang = item.lang === currentLang;
|
|
83
|
+
|
|
82
84
|
return {
|
|
83
85
|
text: item?.label,
|
|
84
|
-
link:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
link: isCurrentLang
|
|
87
|
+
? ''
|
|
88
|
+
: replaceLang(
|
|
89
|
+
pathname + search,
|
|
90
|
+
{
|
|
91
|
+
current: currentLang,
|
|
92
|
+
target: item.lang,
|
|
93
|
+
default: defaultLang,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
current: currentVersion,
|
|
97
|
+
default: defaultVersion,
|
|
98
|
+
},
|
|
99
|
+
cleanUrls,
|
|
100
|
+
pageType === '404',
|
|
101
|
+
),
|
|
98
102
|
lang: item.lang,
|
|
99
103
|
rel: 'alternate',
|
|
100
104
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SocialLinks,
|
|
7
7
|
SwitchAppearance,
|
|
8
8
|
} from '@rspress/core/theme';
|
|
9
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
9
10
|
import './index.scss';
|
|
10
11
|
import { NavLangs, NavMenu, NavMenuDivider, NavVersions } from './NavMenu';
|
|
11
12
|
|
|
@@ -28,7 +29,9 @@ export function Nav(props: NavProps) {
|
|
|
28
29
|
} = props;
|
|
29
30
|
const navList = useNav();
|
|
30
31
|
const { site } = useSite();
|
|
31
|
-
const hasAppearanceSwitch =
|
|
32
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
33
|
+
site.themeConfig.darkMode,
|
|
34
|
+
);
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
37
|
<header className="rp-nav">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { NoSSR, useI18n, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { SwitchAppearance } from '@rspress/core/theme';
|
|
3
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
3
4
|
import './NavScreenAppearance.scss';
|
|
4
5
|
|
|
5
6
|
export function NavScreenAppearance() {
|
|
6
7
|
const { site } = useSite();
|
|
7
|
-
const hasAppearanceSwitch =
|
|
8
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
9
|
+
site.themeConfig.darkMode,
|
|
10
|
+
);
|
|
8
11
|
const t = useI18n();
|
|
9
12
|
return (
|
|
10
13
|
<>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { NoSSR, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { SocialLinks, SwitchAppearance } from '@rspress/core/theme';
|
|
3
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
3
4
|
import './index.scss';
|
|
4
5
|
import { NavScreenLangs } from './NavScreenLangs';
|
|
5
6
|
import { NavScreenVersions } from './NavScreenVersions';
|
|
6
7
|
|
|
7
8
|
export function NavScreenMenuOthers() {
|
|
8
9
|
const { site } = useSite();
|
|
9
|
-
const hasAppearanceSwitch =
|
|
10
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
11
|
+
site.themeConfig.darkMode,
|
|
12
|
+
);
|
|
10
13
|
const socialLinks = site?.themeConfig?.socialLinks || [];
|
|
11
14
|
const hasSocialLinks = socialLinks.length > 0;
|
|
12
15
|
return (
|
|
@@ -51,6 +51,22 @@ const useDebounce = <T extends (...args: any[]) => any>(cb: T) => {
|
|
|
51
51
|
return debounced;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
const normalizeSuggestions = (
|
|
55
|
+
suggestions: DefaultMatchResult['result'],
|
|
56
|
+
): Map<string, DefaultMatchResultItem[]> => {
|
|
57
|
+
return suggestions.reduce(
|
|
58
|
+
(groups, item) => {
|
|
59
|
+
const group = item.title;
|
|
60
|
+
if (!groups.has(group)) {
|
|
61
|
+
groups.set(group, []);
|
|
62
|
+
}
|
|
63
|
+
groups.get(group)!.push(item);
|
|
64
|
+
return groups;
|
|
65
|
+
},
|
|
66
|
+
new Map() as Map<string, DefaultMatchResult['result']>,
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
54
70
|
export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
55
71
|
const [query, setQuery] = useState('');
|
|
56
72
|
const [searchResult, setSearchResult] = useState<MatchResult>([]);
|
|
@@ -277,12 +293,18 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
277
293
|
|
|
278
294
|
// Prefetch the search index when the page is idle
|
|
279
295
|
useEffect(() => {
|
|
296
|
+
let idleCallbackID: number | undefined;
|
|
280
297
|
if ('requestIdleCallback' in window && !pageSearcherRef.current) {
|
|
281
|
-
window.requestIdleCallback(() => {
|
|
298
|
+
idleCallbackID = window.requestIdleCallback(() => {
|
|
282
299
|
const searcher = createSearcher();
|
|
283
300
|
searcher.fetchSearchIndex();
|
|
284
301
|
});
|
|
285
302
|
}
|
|
303
|
+
return () => {
|
|
304
|
+
if (idleCallbackID !== undefined && 'cancelIdleCallback' in window) {
|
|
305
|
+
window.cancelIdleCallback(idleCallbackID);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
286
308
|
}, []);
|
|
287
309
|
|
|
288
310
|
// init pageSearcher again when lang or version changed
|
|
@@ -358,22 +380,6 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
358
380
|
|
|
359
381
|
const handleQueryChange = useDebounce(handleQueryChangedImpl);
|
|
360
382
|
|
|
361
|
-
const normalizeSuggestions = (
|
|
362
|
-
suggestions: DefaultMatchResult['result'],
|
|
363
|
-
): Map<string, DefaultMatchResultItem[]> => {
|
|
364
|
-
return suggestions.reduce(
|
|
365
|
-
(groups, item) => {
|
|
366
|
-
const group = item.title;
|
|
367
|
-
if (!groups.has(group)) {
|
|
368
|
-
groups.set(group, []);
|
|
369
|
-
}
|
|
370
|
-
groups.get(group)!.push(item);
|
|
371
|
-
return groups;
|
|
372
|
-
},
|
|
373
|
-
new Map() as Map<string, DefaultMatchResult['result']>,
|
|
374
|
-
);
|
|
375
|
-
};
|
|
376
|
-
|
|
377
383
|
const renderSearchResult = (result: MatchResult, isSearching: boolean) => {
|
|
378
384
|
if (result.length === 1) {
|
|
379
385
|
const currentSearchResult = result[0]
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { EditLink, Feature, FrontMatterMeta, Header, Hero, I18nText, LocalSearchOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedSidebarGroup, PageIndexInfo, RemotePageInfo, RouteMeta, RspressPlugin, Sidebar, SidebarData, SidebarDivider, SidebarGroup, SidebarItem, SidebarSectionHeader, SocialLink, UserConfig, } from '@rspress/shared';
|
|
1
|
+
export type { DarkMode, EditLink, Feature, FrontMatterMeta, Header, Hero, I18nText, LocalSearchOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedSidebarGroup, PageIndexInfo, RemotePageInfo, RouteMeta, RspressPlugin, Sidebar, SidebarData, SidebarDivider, SidebarGroup, SidebarItem, SidebarSectionHeader, SocialLink, UserConfig, } from '@rspress/shared';
|
|
2
2
|
export { getSidebarDataGroup, normalizeHref, normalizePosixPath, RSPRESS_TEMP_DIR, removeTrailingSlash, withBase, } from '@rspress/shared';
|
|
3
3
|
export { logger } from '@rspress/shared/logger';
|
|
4
4
|
export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shared/node-utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTrailingSlash, node_path, addLeadingSlash } from "../
|
|
1
|
+
import { addTrailingSlash, node_path, addLeadingSlash } from "../6010.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
3
|
import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
|
|
4
4
|
class PluginDriver {
|
|
@@ -25,11 +25,11 @@ class PluginDriver {
|
|
|
25
25
|
this.clearPlugins();
|
|
26
26
|
const config = this.#config;
|
|
27
27
|
const themeConfig = config?.themeConfig || {};
|
|
28
|
-
const
|
|
28
|
+
const lastUpdatedConfig = themeConfig?.lastUpdated;
|
|
29
29
|
const mediumZoomConfig = config?.mediumZoom ?? true;
|
|
30
|
-
if (
|
|
30
|
+
if (lastUpdatedConfig) {
|
|
31
31
|
const { pluginLastUpdated } = await import("./last-updated/index.js");
|
|
32
|
-
this.addPlugin(pluginLastUpdated());
|
|
32
|
+
this.addPlugin(pluginLastUpdated('object' == typeof lastUpdatedConfig ? lastUpdatedConfig.author : false));
|
|
33
33
|
}
|
|
34
34
|
if (mediumZoomConfig) {
|
|
35
35
|
const { pluginMediumZoom } = await import("./medium-zoom/index.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../
|
|
1
|
+
import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../6010.js";
|
|
2
2
|
import { processLocales, combineWalkResult } from "./locales.js";
|
|
3
3
|
import { walk } from "./walk.js";
|
|
4
4
|
async function runAutoNavSide(config, metaFileSet, mdFileSet) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../../0~rslib-runtime.js";
|
|
2
2
|
import "../../7986.js";
|
|
3
|
-
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../
|
|
3
|
+
import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../6010.js";
|
|
4
4
|
import { createError } from "../utils/error.js";
|
|
5
5
|
import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
|
|
6
6
|
import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../
|
|
1
|
+
import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../6010.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
async function pathExists(path) {
|
|
4
4
|
try {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type NavItem
|
|
1
|
+
import { type NavItem } from '@rspress/shared';
|
|
2
2
|
export declare function walk(workDir: string, docsDir: string, extensions: string[], metaFileSet: Set<string>, mdFileSet: Set<string>): Promise<{
|
|
3
3
|
nav: NavItem[];
|
|
4
|
-
sidebar:
|
|
4
|
+
sidebar: {
|
|
5
|
+
[x: string]: (import("@rspress/shared").SidebarDivider | import("@rspress/shared").SidebarGroup | import("@rspress/shared").SidebarItem | import("@rspress/shared").SidebarSectionHeader)[];
|
|
6
|
+
};
|
|
5
7
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isExternalUrl, node_path, promises } from "../../
|
|
1
|
+
import { isExternalUrl, node_path, promises } from "../../6010.js";
|
|
2
2
|
import { pathExists } from "../utils/fs.js";
|
|
3
3
|
import { readJson } from "./utils.js";
|
|
4
4
|
import { addRoutePrefix } from "../route/RoutePage.js";
|
|
@@ -34,7 +34,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
|
34
34
|
return {
|
|
35
35
|
nav: navConfig,
|
|
36
36
|
sidebar: {
|
|
37
|
-
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
37
|
+
[addRoutePrefix(workDir, docsDir, '/')]: await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -57,7 +57,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
|
57
57
|
return {
|
|
58
58
|
nav: [],
|
|
59
59
|
sidebar: {
|
|
60
|
-
'/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
60
|
+
[addRoutePrefix(workDir, docsDir, '/')]: await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
package/dist/node/constants.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type DarkMode } from '@rspress/shared';
|
|
1
2
|
export declare const RSPRESS_VERSION: string;
|
|
2
3
|
export declare const isProduction: () => boolean;
|
|
3
4
|
export declare const importStatementRegex: RegExp;
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const getInlineThemeScript: (darkMode: DarkMode | undefined) => string;
|
|
5
6
|
export declare const PACKAGE_ROOT: string;
|
|
6
7
|
export declare const DEFAULT_THEME: string;
|
|
7
8
|
export declare const EJECTED_THEME: string;
|
package/dist/node/constants.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isDarkModeSwitchEnabled, node_path, package_namespaceObject, getDefaultDarkModeValue, createRequire } from "../9958.js";
|
|
2
2
|
const constants_require = createRequire(import.meta.url);
|
|
3
3
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
4
4
|
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
5
5
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
6
6
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const getInlineThemeScript = (darkMode)=>{
|
|
8
|
+
const defaultTheme = getDefaultDarkModeValue(darkMode);
|
|
9
|
+
const shouldReadStorage = isDarkModeSwitchEnabled(darkMode);
|
|
10
|
+
return `{
|
|
11
|
+
const saved = ${shouldReadStorage ? `localStorage.getItem('${APPEARANCE_KEY}')` : 'null'}
|
|
9
12
|
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
10
|
-
const
|
|
13
|
+
const defaultTheme = '${defaultTheme}'
|
|
14
|
+
const theme = saved === 'light' || saved === 'dark' || saved === 'auto' ? saved : defaultTheme
|
|
15
|
+
const isDark = theme === 'auto' ? preferDark : theme === 'dark'
|
|
11
16
|
document.documentElement.classList.toggle('dark', isDark)
|
|
12
17
|
document.documentElement.classList.toggle('rp-dark', isDark)
|
|
13
18
|
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
14
19
|
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
20
|
+
};
|
|
15
21
|
const PACKAGE_ROOT = node_path.dirname(constants_require.resolve('@rspress/core/package.json'));
|
|
16
22
|
const DEFAULT_THEME = node_path.join(PACKAGE_ROOT, 'dist/theme');
|
|
17
23
|
const EJECTED_THEME = node_path.join(PACKAGE_ROOT, 'dist/eject-theme');
|
|
@@ -25,9 +31,9 @@ const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
|
|
|
25
31
|
const HEAD_MARKER = '<!--<?- HEAD ?>-->';
|
|
26
32
|
const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
|
|
27
33
|
const DEFAULT_TITLE = 'Rspress';
|
|
34
|
+
const PUBLIC_DIR = 'public';
|
|
28
35
|
const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
|
|
29
36
|
const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
|
|
30
37
|
const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
|
|
31
38
|
const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
|
|
32
|
-
|
|
33
|
-
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, constants_PUBLIC_DIR as PUBLIC_DIR, importStatementRegex, inlineThemeScript, isProduction };
|
|
39
|
+
export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, getInlineThemeScript, importStatementRegex, isProduction };
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash,
|
|
1
|
+
import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, normalizeDarkMode, pluginReact, pluginVirtualModule, MDX_OR_MD_REGEXP } from "../6010.js";
|
|
2
2
|
import { createError } from "./utils/error.js";
|
|
3
|
-
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY,
|
|
3
|
+
import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
|
|
4
4
|
import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
|
|
5
5
|
import { resolveReactRouterDomAlias, resolveReactRenderToMarkdownAlias, resolveReactAlias } from "./utils/reactAlias.js";
|
|
6
6
|
import { rsbuildPluginDocVM } from "./runtimeModule/pageData/rsbuildPlugin.js";
|
|
@@ -14,7 +14,7 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
|
|
|
14
14
|
import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
|
|
15
15
|
import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
|
|
16
16
|
import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
|
|
17
|
-
import { package_namespaceObject } from "../
|
|
17
|
+
import { package_namespaceObject } from "../9958.js";
|
|
18
18
|
function isPluginIncluded(config, pluginName) {
|
|
19
19
|
return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
|
|
20
20
|
}
|
|
@@ -116,9 +116,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
116
116
|
favicon: normalizeIcon(config?.icon),
|
|
117
117
|
template: TEMPLATE_PATH,
|
|
118
118
|
tags: [
|
|
119
|
-
config.themeConfig?.darkMode
|
|
119
|
+
'force-light' !== normalizeDarkMode(config.themeConfig?.darkMode) ? {
|
|
120
120
|
tag: "script",
|
|
121
|
-
children:
|
|
121
|
+
children: getInlineThemeScript(config.themeConfig?.darkMode),
|
|
122
122
|
append: false
|
|
123
123
|
} : null
|
|
124
124
|
].filter(Boolean)
|
|
@@ -162,6 +162,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
164
|
performance: {
|
|
165
|
+
printFileSize: {
|
|
166
|
+
compressed: true
|
|
167
|
+
},
|
|
165
168
|
...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
|
|
166
169
|
buildCache: {
|
|
167
170
|
buildDependencies: [
|
|
@@ -293,11 +296,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
293
296
|
'import.meta.env.SSG_MD': JSON.stringify(false)
|
|
294
297
|
}
|
|
295
298
|
},
|
|
296
|
-
performance: {
|
|
297
|
-
printFileSize: {
|
|
298
|
-
compressed: true
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
299
|
tools: {
|
|
302
300
|
rspack: {
|
|
303
301
|
optimization: NODE_RSPACK_OPTIMIZATION
|
|
@@ -335,11 +333,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
335
333
|
'import.meta.env.SSG_MD': JSON.stringify(true)
|
|
336
334
|
}
|
|
337
335
|
},
|
|
338
|
-
performance: {
|
|
339
|
-
printFileSize: {
|
|
340
|
-
compressed: true
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
336
|
output: {
|
|
344
337
|
emitAssets: false,
|
|
345
338
|
target: 'node',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RspressPlugin } from '@rspress/shared';
|
|
1
|
+
import type { LastUpdatedAuthor, RspressPlugin } from '@rspress/shared';
|
|
2
2
|
/**
|
|
3
|
-
* The plugin is used to add the last updated time to the page.
|
|
3
|
+
* The plugin is used to add the last updated time and author to the page.
|
|
4
4
|
*/
|
|
5
|
-
export declare function pluginLastUpdated(): RspressPlugin;
|
|
5
|
+
export declare function pluginLastUpdated(authorOption?: LastUpdatedAuthor): RspressPlugin;
|
|
@@ -2,26 +2,41 @@ import { execa } from "../../0~execa.js";
|
|
|
2
2
|
function transform(timestamp, lang) {
|
|
3
3
|
return new Date(timestamp).toLocaleString(lang || 'zh');
|
|
4
4
|
}
|
|
5
|
-
async function
|
|
6
|
-
let lastUpdated;
|
|
5
|
+
async function getGitInfo(filePath) {
|
|
7
6
|
try {
|
|
8
7
|
const { stdout } = await execa('git', [
|
|
9
8
|
'log',
|
|
10
9
|
'-1',
|
|
11
|
-
'--format=%at',
|
|
10
|
+
'--format=%at%n%an%n%ae',
|
|
11
|
+
'--',
|
|
12
12
|
filePath
|
|
13
13
|
]);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const [at, an, ae] = stdout.split('\n');
|
|
15
|
+
if (!at) return;
|
|
16
|
+
return {
|
|
17
|
+
timestamp: 1000 * Number(at),
|
|
18
|
+
authorName: an ?? '',
|
|
19
|
+
authorEmail: ae ?? ''
|
|
20
|
+
};
|
|
21
|
+
} catch (_e) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
|
-
function pluginLastUpdated() {
|
|
25
|
+
function pluginLastUpdated(authorOption = false) {
|
|
19
26
|
return {
|
|
20
27
|
name: '@rspress/plugin-last-updated',
|
|
21
28
|
async extendPageData (pageData) {
|
|
22
29
|
const { _filepath, lang } = pageData;
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
30
|
+
const info = await getGitInfo(_filepath);
|
|
31
|
+
if (!info) return;
|
|
32
|
+
pageData.lastUpdatedTime = transform(info.timestamp, lang);
|
|
33
|
+
if (false === authorOption) return;
|
|
34
|
+
const display = 'function' == typeof authorOption ? authorOption({
|
|
35
|
+
name: info.authorName,
|
|
36
|
+
email: info.authorEmail,
|
|
37
|
+
filePath: _filepath
|
|
38
|
+
}) : info.authorName;
|
|
39
|
+
pageData.lastUpdatedAuthor = display;
|
|
25
40
|
}
|
|
26
41
|
};
|
|
27
42
|
}
|
package/dist/node/mdx/options.js
CHANGED
|
@@ -28,7 +28,13 @@ async function createMDXOptions(options) {
|
|
|
28
28
|
remark_gfm,
|
|
29
29
|
cjkFriendlyEmphasis && remark_cjk_friendly,
|
|
30
30
|
cjkFriendlyEmphasis && remark_cjk_friendly_gfm_strikethrough,
|
|
31
|
-
|
|
31
|
+
[
|
|
32
|
+
remarkToc,
|
|
33
|
+
{
|
|
34
|
+
routeService,
|
|
35
|
+
fallbackHeadingTitle: config?.themeConfig?.fallbackHeadingTitle
|
|
36
|
+
}
|
|
37
|
+
],
|
|
32
38
|
!isSsgMd && remarkContainerSyntax,
|
|
33
39
|
[
|
|
34
40
|
remarkFileCodeBlock,
|
|
@@ -46,6 +52,7 @@ async function createMDXOptions(options) {
|
|
|
46
52
|
routeService,
|
|
47
53
|
remarkLinkOptions: {
|
|
48
54
|
checkDeadLinks: false,
|
|
55
|
+
checkAnchors: false,
|
|
49
56
|
autoPrefix: true
|
|
50
57
|
},
|
|
51
58
|
__base: config?.base
|
|
@@ -29,7 +29,9 @@ async function compile(options) {
|
|
|
29
29
|
const compiler = createProcessor(mdxOptions);
|
|
30
30
|
compiler.data('pageMeta', {
|
|
31
31
|
toc: [],
|
|
32
|
-
title: ''
|
|
32
|
+
title: '',
|
|
33
|
+
headingTitle: '',
|
|
34
|
+
frontmatter
|
|
33
35
|
});
|
|
34
36
|
const vFile = await compiler.process({
|
|
35
37
|
value: preprocessedContent,
|