@rspress/core 2.0.0-rc.3 → 2.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{0~7675.723d12b2.js → 0~7675.4468968d.js} +4 -4
- package/dist/1820.985588a0.js +5 -0
- package/dist/{3521.56e42d70.js → 5341.9eb6b114.js} +12 -12
- package/dist/{5485.077f14ff.js → 5485.b9ce9bdf.js} +5 -5
- package/dist/6289.29817fb4.js +4 -0
- package/dist/8813.4b28f4bb.js +1 -0
- package/dist/_private/react/render.js +1 -1
- package/dist/cli/config/loadConfigFile.js +2 -2
- package/dist/cli/index.44f3184c.js +2 -0
- package/dist/cli/index.js +3 -3
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
- package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
- package/dist/eject-theme/components/HomeHero/index.scss +8 -0
- package/dist/eject-theme/components/HomeHero/index.tsx +11 -2
- package/dist/eject-theme/components/HoverGroup/index.scss +3 -2
- package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
- package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
- package/dist/eject-theme/components/Overview/index.tsx +11 -0
- package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
- package/dist/eject-theme/components/Steps/index.scss +1 -0
- package/dist/index.js +6 -11
- package/dist/node/PluginDriver.js +3 -3
- package/dist/node/auto-nav-sidebar/index.js +3 -3
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +2 -2
- package/dist/node/auto-nav-sidebar/utils.js +2 -2
- package/dist/node/auto-nav-sidebar/walk.js +13 -9
- package/dist/node/constants.js +2 -2
- package/dist/node/eject.js +2 -5
- package/dist/node/initRsbuild.js +14 -9
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.js +1 -1
- package/dist/node/mdx/loader.7c249a26.js +12 -0
- package/dist/node/mdx/options.js +3 -3
- package/dist/node/mdx/processor.js +2 -2
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
- package/dist/node/mdx/remarkPlugins/image.js +2 -3
- package/dist/node/mdx/remarkPlugins/link.js +3 -3
- package/dist/node/mdx/remarkPlugins/toc.js +3 -3
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +3 -3
- package/dist/node/route/extractPageData.js +4 -5
- package/dist/node/route/normalizeRoutePath.js +2 -2
- package/dist/node/runtimeModule/i18n.js +2 -2
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- 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/renderPage.js +2 -2
- package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +3 -3
- package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -7
- package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +4 -5
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +3 -3
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +4 -2
- package/dist/runtime/Content.d.ts +4 -0
- package/dist/runtime/Content.js +18 -0
- package/dist/runtime/NoSSR.d.ts +3 -0
- package/dist/runtime/NoSSR.js +14 -0
- package/dist/runtime/getSidebarDataGroup.test.js +68 -0
- package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
- package/dist/runtime/hooks/useActiveMatcher.js +14 -0
- package/dist/runtime/hooks/useDark.d.ts +7 -0
- package/dist/runtime/hooks/useDark.js +7 -0
- package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
- package/dist/runtime/hooks/useFrontmatter.js +9 -0
- package/dist/runtime/hooks/useI18n.d.ts +2 -0
- package/dist/runtime/hooks/useI18n.js +14 -0
- package/dist/runtime/hooks/useLang.d.ts +1 -0
- package/dist/runtime/hooks/useLang.js +6 -0
- package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
- package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
- package/dist/runtime/hooks/useNav.d.ts +1 -0
- package/dist/runtime/hooks/useNav.js +12 -0
- package/dist/runtime/hooks/usePage.d.ts +10 -0
- package/dist/runtime/hooks/usePage.js +9 -0
- package/dist/runtime/hooks/usePageData.d.ts +5 -0
- package/dist/runtime/hooks/usePageData.js +16 -0
- package/dist/runtime/hooks/usePages.d.ts +4 -0
- package/dist/runtime/hooks/usePages.js +7 -0
- package/dist/runtime/hooks/useSidebar.d.ts +16 -0
- package/dist/runtime/hooks/useSidebar.js +67 -0
- package/dist/runtime/hooks/useSite.d.ts +4 -0
- package/dist/runtime/hooks/useSite.js +7 -0
- package/dist/runtime/hooks/useVersion.d.ts +1 -0
- package/dist/runtime/hooks/useVersion.js +6 -0
- package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
- package/dist/runtime/hooks/useWindowSize.js +31 -0
- package/dist/runtime/hooks/useWindowSize.test.js +36 -0
- package/dist/runtime/index.d.ts +21 -0
- package/dist/runtime/index.js +22 -0
- package/dist/runtime/route.d.ts +36 -0
- package/dist/runtime/route.js +53 -0
- package/dist/runtime/route.test.js +154 -0
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/runtime/utils.d.ts +12 -0
- package/dist/runtime/utils.js +34 -0
- package/dist/runtime/utils.test.js +34 -0
- package/dist/shiki-transformers.js +2 -2
- package/dist/theme/components/CodeBlock/index.js +1 -1
- package/dist/theme/components/FallbackHeading/index.js +4 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
- package/dist/theme/components/HomeHero/index.css +6 -0
- package/dist/theme/components/HomeHero/index.js +10 -3
- package/dist/theme/components/HoverGroup/index.css +3 -2
- package/dist/theme/components/HoverGroup/index.js +88 -17
- package/dist/theme/components/Nav/NavMenu.css +1 -1
- package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
- package/dist/theme/components/Nav/NavMenu.js +47 -45
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
- package/dist/theme/components/Overview/index.js +12 -1
- package/dist/theme/components/OverviewGroup/index.js +33 -0
- package/dist/theme/components/Steps/index.css +1 -0
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/layout/DocLayout/index.js +10 -0
- package/dist/theme/layout/HomeLayout/index.js +40 -0
- package/dist/theme/layout/Layout/index.js +10 -6
- package/dist/theme/logic/useScrollAfterNav.js +2 -2
- package/dist/theme/logic/useScrollReset.js +2 -2
- package/dist/theme/logic/useStorageValue.js +6 -3
- package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
- package/dist/theme/logic/useThemeState.js +50 -0
- package/dist/theme/styles/scrollbar.css +14 -2
- package/dist/theme/styles/vars/base-vars.css +2 -2
- package/dist/theme/styles/vars/code-vars.css +2 -2
- package/nav-json-schema.json +2 -2
- package/package.json +10 -11
- package/static/MediumZoom.tsx +1 -1
- package/dist/4669.12208c6a.js +0 -2
- package/dist/6289.c67fe0d5.js +0 -5
- package/dist/8813.9da1f210.js +0 -2
- package/dist/9643.f109822d.js +0 -5
- package/dist/cli/index.cb89dbd1.js +0 -3
- package/dist/node/mdx/loader.e1578c62.js +0 -13
- package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
- package/dist/runtime.72d450ac.js +0 -1
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.js +0 -4
- package/dist/theme/logic/useAppearance.js +0 -64
|
@@ -7,10 +7,10 @@ import { Buffer } from "node:buffer";
|
|
|
7
7
|
import node_child_process, { ChildProcess } from "node:child_process";
|
|
8
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
|
-
import { node_process, node_os, constants } from "./
|
|
11
|
-
import { node_path } from "./6289.
|
|
12
|
-
import { node_url } from "./5485.
|
|
13
|
-
import { createWriteStream, createReadStream, readFileSync } from "./
|
|
10
|
+
import { node_process, node_os, constants } from "./1820.985588a0.js";
|
|
11
|
+
import { node_path } from "./6289.29817fb4.js";
|
|
12
|
+
import { node_url } from "./5485.b9ce9bdf.js";
|
|
13
|
+
import { createWriteStream, createReadStream, readFileSync } from "./5341.9eb6b114.js";
|
|
14
14
|
__webpack_require__.add({
|
|
15
15
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
16
16
|
const cp = __webpack_require__("child_process");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, normalizePosixPath, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2
|
+
export { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, mergeDocConfig } from "@rspress/shared/node-utils";
|
|
3
|
+
export { constants, default as node_os } from "node:os";
|
|
4
|
+
export { cwd, default as node_process } from "node:process";
|
|
5
|
+
export { createProcessor, nodeTypes } from "@mdx-js/mdx";
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
3
|
-
import { glob } from "tinyglobby";
|
|
4
|
-
import { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
5
|
-
import { chunk, groupBy } from "lodash-es";
|
|
6
|
-
import { compile } from "@rspress/mdx-rs";
|
|
7
|
-
import { htmlToText } from "html-to-text";
|
|
8
|
-
import node_fs, { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
9
|
-
import { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
11
|
-
import { extname, join } from "./6289.c67fe0d5.js";
|
|
1
|
+
import { extname, join } from "./6289.29817fb4.js";
|
|
12
2
|
const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
|
|
13
3
|
const pluginVirtualModule = (pluginOptions = {})=>({
|
|
14
4
|
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
@@ -53,4 +43,14 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
45
|
});
|
|
56
|
-
export {
|
|
46
|
+
export { matchPath } from "react-router-dom";
|
|
47
|
+
export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
48
|
+
export { glob } from "tinyglobby";
|
|
49
|
+
export { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
50
|
+
export { chunk, groupBy } from "lodash-es";
|
|
51
|
+
export { compile } from "@rspress/mdx-rs";
|
|
52
|
+
export { htmlToText } from "html-to-text";
|
|
53
|
+
export { createReadStream, createWriteStream, default as node_fs, readFileSync } from "node:fs";
|
|
54
|
+
export { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
55
|
+
export { createHash } from "node:crypto";
|
|
56
|
+
export { pluginVirtualModule };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import node_url, { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
-
import { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
4
1
|
var package_namespaceObject = {
|
|
5
|
-
rE: "2.0.0-rc.
|
|
2
|
+
rE: "2.0.0-rc.5"
|
|
6
3
|
};
|
|
7
4
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
8
5
|
return new Promise((resolve_, reject_)=>{
|
|
@@ -95,4 +92,7 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
|
|
|
95
92
|
});
|
|
96
93
|
}
|
|
97
94
|
const pMapSkip = Symbol('skip');
|
|
98
|
-
export {
|
|
95
|
+
export { createRequire } from "node:module";
|
|
96
|
+
export { default as node_url, fileURLToPath, pathToFileURL } from "node:url";
|
|
97
|
+
export { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
98
|
+
export { pMap, package_namespaceObject };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { logger } from "@rspress/shared/logger";
|
|
2
|
+
export { default as node_path, extname, join, relative } from "node:path";
|
|
3
|
+
export { default as promises, mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
export { default as picocolors } from "picocolors";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { visit } from "unist-util-visit";
|
|
@@ -100,7 +100,7 @@ async function renderToMarkdownString(element) {
|
|
|
100
100
|
const root = reconciler.createContainer(container, 1, null, false, false, '', (error, info)=>{
|
|
101
101
|
if (process.env.DEBUG) {
|
|
102
102
|
console.error('Reconciler Error:', error, info);
|
|
103
|
-
const message =
|
|
103
|
+
const message = `Reconciler Error:${error.message}`;
|
|
104
104
|
throw new Error(message);
|
|
105
105
|
}
|
|
106
106
|
}, ()=>{}, (...args)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../
|
|
2
|
-
import { node_path, logger } from "../../6289.
|
|
1
|
+
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../5341.9eb6b114.js";
|
|
2
|
+
import { node_path, logger } from "../../6289.29817fb4.js";
|
|
3
3
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
4
4
|
async function loadConfigFile(customConfigFile) {
|
|
5
5
|
const baseDir = process.cwd();
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { node_path, logger, join, picocolors } from "../6289.
|
|
2
|
-
import { chokidar, cac } from "./index.
|
|
3
|
-
import { package_namespaceObject } from "../5485.
|
|
1
|
+
import { node_path, logger, join, picocolors } from "../6289.29817fb4.js";
|
|
2
|
+
import { chokidar, cac } from "./index.44f3184c.js";
|
|
3
|
+
import { package_namespaceObject } from "../5485.b9ce9bdf.js";
|
|
4
4
|
import { loadConfigFile, resolveDocRoot } from "./config/loadConfigFile.js";
|
|
5
5
|
import { dev } from "../node/dev.js";
|
|
6
6
|
import { PUBLIC_DIR } from "../node/constants.js";
|
|
@@ -28,6 +28,10 @@ export function FallbackHeading({
|
|
|
28
28
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
29
29
|
title: string;
|
|
30
30
|
}) {
|
|
31
|
+
if (process.env.__SSR_MD__) {
|
|
32
|
+
return <>{`${'#'.repeat(level)} ${title}\n\n`}</>;
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
const titleSlug = title && slug(title.trim());
|
|
32
36
|
|
|
33
37
|
const Element = useMemo(() => {
|
|
@@ -36,7 +36,8 @@ export const useNavTransparent = () => {
|
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<style>
|
|
39
|
-
{'body:not(.notTopArrived)
|
|
39
|
+
{'body:not(.notTopArrived) ' +
|
|
40
|
+
'.rp-nav {background: transparent !important; border-bottom: 1px solid transparent !important;}' +
|
|
40
41
|
// TODO: discussion
|
|
41
42
|
'.rp-nav {background: color-mix(in srgb,var(--rp-c-bg) 60%,transparent);backdrop-filter: blur(25px);}'}
|
|
42
43
|
</style>
|
|
@@ -78,11 +78,19 @@
|
|
|
78
78
|
font-size: 0.875rem;
|
|
79
79
|
font-weight: 500;
|
|
80
80
|
color: var(--rp-c-text-0);
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
transition:
|
|
83
|
+
background 0.2s,
|
|
84
|
+
border-color 0.2s;
|
|
81
85
|
|
|
82
86
|
&:hover {
|
|
83
87
|
background: var(--rp-c-bg-mute);
|
|
84
88
|
cursor: pointer;
|
|
85
89
|
}
|
|
90
|
+
|
|
91
|
+
&:is(a):hover {
|
|
92
|
+
border-color: var(--rp-c-brand);
|
|
93
|
+
}
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
&__title {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FrontMatterMeta } from '@rspress/core';
|
|
2
2
|
import { normalizeImagePath, useFrontmatter } from '@rspress/core/runtime';
|
|
3
|
-
import { Button, renderHtmlOrText } from '@theme';
|
|
3
|
+
import { Button, Link, renderHtmlOrText } from '@theme';
|
|
4
4
|
|
|
5
5
|
import './index.scss';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -39,7 +39,16 @@ function HomeHero({ beforeHeroActions, afterHeroActions }: HomeHeroProps) {
|
|
|
39
39
|
className={clsx('rp-home-hero', { 'rp-home-hero--no-image': !hasImage })}
|
|
40
40
|
>
|
|
41
41
|
<div className="rp-home-hero__container">
|
|
42
|
-
{hero.badge &&
|
|
42
|
+
{hero.badge &&
|
|
43
|
+
(typeof hero.badge === 'string' ? (
|
|
44
|
+
<div className="rp-home-hero__badge">{hero.badge}</div>
|
|
45
|
+
) : hero.badge.link ? (
|
|
46
|
+
<Link href={hero.badge.link} className="rp-home-hero__badge">
|
|
47
|
+
{hero.badge.text}
|
|
48
|
+
</Link>
|
|
49
|
+
) : (
|
|
50
|
+
<div className="rp-home-hero__badge">{hero.badge.text}</div>
|
|
51
|
+
))}
|
|
43
52
|
<div className="rp-home-hero__content">
|
|
44
53
|
<div className="rp-home-hero__title">
|
|
45
54
|
<span
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
display: block;
|
|
50
50
|
white-space: nowrap;
|
|
51
51
|
|
|
52
|
-
padding-left: 8px;
|
|
53
52
|
padding-right: 8px;
|
|
54
53
|
|
|
55
54
|
// style
|
|
@@ -64,8 +63,10 @@
|
|
|
64
63
|
line-height: 32px;
|
|
65
64
|
|
|
66
65
|
&__link {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: 2px;
|
|
67
69
|
// For click area
|
|
68
|
-
display: block;
|
|
69
70
|
height: 100%;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NavItemWithChildren } from '@rspress/core';
|
|
2
|
-
import {
|
|
2
|
+
import { matchNavbar, useLocation } from '@rspress/core/runtime';
|
|
3
|
+
import { Link, Tag } from '@theme';
|
|
3
4
|
import cls from 'clsx';
|
|
5
|
+
|
|
4
6
|
import './index.scss';
|
|
5
7
|
|
|
6
8
|
type Items = NavItemWithChildren['items'];
|
|
@@ -17,6 +19,100 @@ interface HoverGroupProps {
|
|
|
17
19
|
activeMatcher?: (item: Items[number]) => boolean;
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
function HoverGroupItem({
|
|
23
|
+
item,
|
|
24
|
+
activeMatcher,
|
|
25
|
+
depth = 0,
|
|
26
|
+
}: {
|
|
27
|
+
item: Items[number];
|
|
28
|
+
activeMatcher?: (item: Items[number]) => boolean;
|
|
29
|
+
depth?: number;
|
|
30
|
+
}) {
|
|
31
|
+
const { pathname } = useLocation();
|
|
32
|
+
|
|
33
|
+
if ('items' in item && item.items && item.items.length > 0) {
|
|
34
|
+
const hasLink = 'link' in item && item.link;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
{hasLink && (
|
|
39
|
+
<li
|
|
40
|
+
key={item.text}
|
|
41
|
+
className="rp-hover-group__item"
|
|
42
|
+
style={{ paddingLeft: `${8 + depth * 12}px` }}
|
|
43
|
+
data-depth={depth}
|
|
44
|
+
>
|
|
45
|
+
<Link
|
|
46
|
+
href={item.link}
|
|
47
|
+
aria-label={item.text}
|
|
48
|
+
className="rp-hover-group__item__link"
|
|
49
|
+
>
|
|
50
|
+
{item.text}
|
|
51
|
+
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
52
|
+
</Link>
|
|
53
|
+
</li>
|
|
54
|
+
)}
|
|
55
|
+
{item.items.map(subItem => (
|
|
56
|
+
<HoverGroupItem
|
|
57
|
+
key={subItem.text}
|
|
58
|
+
item={subItem}
|
|
59
|
+
activeMatcher={activeMatcher}
|
|
60
|
+
depth={depth + 1}
|
|
61
|
+
/>
|
|
62
|
+
))}
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ('link' in item) {
|
|
68
|
+
const { text, link } = item;
|
|
69
|
+
const isActiveItem = activeMatcher
|
|
70
|
+
? activeMatcher(item)
|
|
71
|
+
: matchNavbar(item, pathname);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<li
|
|
75
|
+
key={text + link}
|
|
76
|
+
className={cls('rp-hover-group__item', {
|
|
77
|
+
'rp-hover-group__item--active': isActiveItem,
|
|
78
|
+
})}
|
|
79
|
+
style={{ paddingLeft: `${8 + depth * 12}px` }}
|
|
80
|
+
data-depth={depth}
|
|
81
|
+
>
|
|
82
|
+
{link ? (
|
|
83
|
+
<Link
|
|
84
|
+
href={link}
|
|
85
|
+
aria-label={text}
|
|
86
|
+
className="rp-hover-group__item__link"
|
|
87
|
+
>
|
|
88
|
+
{text}
|
|
89
|
+
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
90
|
+
</Link>
|
|
91
|
+
) : (
|
|
92
|
+
<div className="rp-hover-group__item__link">
|
|
93
|
+
{text}
|
|
94
|
+
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</li>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<li
|
|
103
|
+
key={item.text}
|
|
104
|
+
className="rp-hover-group__item"
|
|
105
|
+
style={{ paddingLeft: `${8 + depth * 12}px` }}
|
|
106
|
+
data-depth={depth}
|
|
107
|
+
>
|
|
108
|
+
<div className="rp-hover-group__item__link">
|
|
109
|
+
{item.text}
|
|
110
|
+
{'tag' in item && item.tag && <Tag tag={item.tag} />}
|
|
111
|
+
</div>
|
|
112
|
+
</li>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
20
116
|
function HoverGroup({
|
|
21
117
|
items,
|
|
22
118
|
customChildren,
|
|
@@ -34,27 +130,13 @@ function HoverGroup({
|
|
|
34
130
|
})}
|
|
35
131
|
>
|
|
36
132
|
{customChildren ??
|
|
37
|
-
items?.map(item =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
className={cls('rp-hover-group__item', {
|
|
45
|
-
'rp-hover-group__item--active': isActiveItem,
|
|
46
|
-
})}
|
|
47
|
-
>
|
|
48
|
-
<Link
|
|
49
|
-
href={link}
|
|
50
|
-
aria-label={text}
|
|
51
|
-
className="rp-hover-group__item__link"
|
|
52
|
-
>
|
|
53
|
-
{text}
|
|
54
|
-
</Link>
|
|
55
|
-
</li>
|
|
56
|
-
);
|
|
57
|
-
})}
|
|
133
|
+
items?.map(item => (
|
|
134
|
+
<HoverGroupItem
|
|
135
|
+
key={item.text}
|
|
136
|
+
item={item}
|
|
137
|
+
activeMatcher={activeMatcher}
|
|
138
|
+
/>
|
|
139
|
+
))}
|
|
58
140
|
</ul>
|
|
59
141
|
);
|
|
60
142
|
}
|
|
@@ -8,7 +8,7 @@ import { matchNavbar, useLocation } from '@rspress/core/runtime';
|
|
|
8
8
|
import type { HoverGroupProps } from '@theme';
|
|
9
9
|
import { IconArrowDown, Link, SvgWrapper, Tag, useHoverGroup } from '@theme';
|
|
10
10
|
import cls from 'clsx';
|
|
11
|
-
import { useMemo } from 'react';
|
|
11
|
+
import { type ReactNode, useMemo } from 'react';
|
|
12
12
|
import { useLangsMenu, useVersionsMenu } from './hooks';
|
|
13
13
|
import './NavMenu.scss';
|
|
14
14
|
import clsx from 'clsx';
|
|
@@ -17,6 +17,32 @@ export const SvgDown = (props: React.SVGProps<SVGSVGElement>) => {
|
|
|
17
17
|
return <SvgWrapper icon={IconArrowDown} {...props} />;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
export function NavMenuItemInner({
|
|
21
|
+
menuItem,
|
|
22
|
+
children,
|
|
23
|
+
}: {
|
|
24
|
+
menuItem: Partial<NavItemWithLink>;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
}) {
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{'link' in menuItem && typeof menuItem.link === 'string' ? (
|
|
30
|
+
<Link href={menuItem.link} className="rp-nav-menu__item__container">
|
|
31
|
+
{menuItem.text}
|
|
32
|
+
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
33
|
+
{children}
|
|
34
|
+
</Link>
|
|
35
|
+
) : (
|
|
36
|
+
<div className="rp-nav-menu__item__container">
|
|
37
|
+
{menuItem.text}
|
|
38
|
+
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
20
46
|
export function NavMenuItemWithChildren({
|
|
21
47
|
menuItem,
|
|
22
48
|
activeMatcher,
|
|
@@ -29,33 +55,20 @@ export function NavMenuItemWithChildren({
|
|
|
29
55
|
activeMatcher,
|
|
30
56
|
});
|
|
31
57
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{menuItem.text}
|
|
36
|
-
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
37
|
-
<SvgDown className="rp-nav-menu__item__icon" />
|
|
38
|
-
</Link>
|
|
39
|
-
) : (
|
|
40
|
-
<div className="rp-nav-menu__item__container">
|
|
41
|
-
{menuItem.text}
|
|
42
|
-
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
43
|
-
<SvgDown className="rp-nav-menu__item__icon" />
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return menuItem.items.length > 0 ? (
|
|
58
|
+
const hasItems = menuItem.items.length > 0;
|
|
59
|
+
|
|
60
|
+
return (
|
|
48
61
|
<li
|
|
49
62
|
className="rp-nav-menu__item"
|
|
50
63
|
onMouseEnter={handleMouseEnter}
|
|
51
64
|
onMouseLeave={handleMouseLeave}
|
|
52
65
|
onClick={handleMouseEnter}
|
|
53
66
|
>
|
|
54
|
-
{
|
|
67
|
+
<NavMenuItemInner menuItem={menuItem}>
|
|
68
|
+
{hasItems && <SvgDown className="rp-nav-menu__item__icon" />}
|
|
69
|
+
</NavMenuItemInner>
|
|
55
70
|
{hoverGroup}
|
|
56
71
|
</li>
|
|
57
|
-
) : (
|
|
58
|
-
<li className="rp-nav-menu__item">{inner}</li>
|
|
59
72
|
);
|
|
60
73
|
}
|
|
61
74
|
|
|
@@ -80,20 +93,29 @@ export function NavMenuItemWithLink({
|
|
|
80
93
|
isActive ? 'rspress-nav-menu-item-active' : '',
|
|
81
94
|
)}
|
|
82
95
|
>
|
|
83
|
-
<
|
|
84
|
-
{menuItem.text}
|
|
85
|
-
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
86
|
-
</Link>
|
|
96
|
+
<NavMenuItemInner menuItem={menuItem} />
|
|
87
97
|
</li>
|
|
88
98
|
);
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
export function NavMenuItem({ menuItem
|
|
92
|
-
if (
|
|
93
|
-
|
|
101
|
+
export function NavMenuItem({ menuItem }: { menuItem: NavItem }) {
|
|
102
|
+
if (
|
|
103
|
+
'items' in menuItem &&
|
|
104
|
+
Array.isArray(menuItem.items) &&
|
|
105
|
+
menuItem.items.length > 0
|
|
106
|
+
) {
|
|
107
|
+
return <NavMenuItemWithChildren menuItem={menuItem} />;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ('link' in menuItem && menuItem.link.length > 0) {
|
|
111
|
+
return <NavMenuItemWithLink menuItem={menuItem as NavItemWithLink} />;
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
return
|
|
114
|
+
return (
|
|
115
|
+
<li className="rp-nav-menu__item">
|
|
116
|
+
<NavMenuItemInner menuItem={menuItem} />
|
|
117
|
+
</li>
|
|
118
|
+
);
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
export function NavMenuDivider() {
|
|
@@ -40,6 +40,7 @@ export function NavScreenMenuItemRaw({
|
|
|
40
40
|
href={href}
|
|
41
41
|
className={clsx(
|
|
42
42
|
'rp-nav-screen-menu-item',
|
|
43
|
+
isOpen && 'rp-nav-screen-menu-item--open',
|
|
43
44
|
isActive && 'rp-nav-screen-menu-item--active',
|
|
44
45
|
)}
|
|
45
46
|
onClick={onClick}
|
|
@@ -97,7 +98,7 @@ export function NavScreenMenuItemWithChildren({
|
|
|
97
98
|
}: NavScreenMenuItemWithChildrenProps) {
|
|
98
99
|
const [isOpen, setIsOpen] = useState(false);
|
|
99
100
|
|
|
100
|
-
return
|
|
101
|
+
return (
|
|
101
102
|
<>
|
|
102
103
|
<NavScreenMenuItemRaw
|
|
103
104
|
left={
|
|
@@ -109,6 +110,7 @@ export function NavScreenMenuItemWithChildren({
|
|
|
109
110
|
right={<SvgDown className="rp-nav-screen-menu-item__icon" />}
|
|
110
111
|
isOpen={isOpen}
|
|
111
112
|
onClick={() => setIsOpen(!isOpen)}
|
|
113
|
+
href={'link' in menuItem ? menuItem.link : undefined}
|
|
112
114
|
/>
|
|
113
115
|
|
|
114
116
|
<div
|
|
@@ -122,16 +124,11 @@ export function NavScreenMenuItemWithChildren({
|
|
|
122
124
|
>
|
|
123
125
|
<div className="rp-nav-screen-menu-item__group-inner">
|
|
124
126
|
{menuItem.items.map(item => (
|
|
125
|
-
<
|
|
126
|
-
key={item.text}
|
|
127
|
-
menuItem={item as any}
|
|
128
|
-
/>
|
|
127
|
+
<NavScreenMenuItem key={item.text} menuItem={item} />
|
|
129
128
|
))}
|
|
130
129
|
</div>
|
|
131
130
|
</div>
|
|
132
131
|
</>
|
|
133
|
-
) : (
|
|
134
|
-
<NavScreenMenuItemWithLink menuItem={menuItem as NavItemWithLink} />
|
|
135
132
|
);
|
|
136
133
|
}
|
|
137
134
|
|
|
@@ -139,10 +136,28 @@ interface NavScreenMenuItemProps {
|
|
|
139
136
|
menuItem: NavItem;
|
|
140
137
|
}
|
|
141
138
|
|
|
142
|
-
export function NavScreenMenuItem({ menuItem
|
|
143
|
-
if (
|
|
144
|
-
|
|
139
|
+
export function NavScreenMenuItem({ menuItem }: NavScreenMenuItemProps) {
|
|
140
|
+
if (
|
|
141
|
+
'items' in menuItem &&
|
|
142
|
+
Array.isArray(menuItem.items) &&
|
|
143
|
+
menuItem.items.length > 0
|
|
144
|
+
) {
|
|
145
|
+
return <NavScreenMenuItemWithChildren menuItem={menuItem} />;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if ('link' in menuItem && typeof menuItem.link === 'string') {
|
|
149
|
+
return <NavScreenMenuItemWithLink menuItem={menuItem as NavItemWithLink} />;
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
return
|
|
152
|
+
return (
|
|
153
|
+
<NavScreenMenuItemRaw
|
|
154
|
+
left={
|
|
155
|
+
<>
|
|
156
|
+
{menuItem.text}
|
|
157
|
+
{menuItem.tag && <Tag tag={menuItem.tag} />}
|
|
158
|
+
</>
|
|
159
|
+
}
|
|
160
|
+
right={null}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
148
163
|
}
|
|
@@ -240,6 +240,17 @@ export function Overview(props: {
|
|
|
240
240
|
|
|
241
241
|
const overviewTitle = title || 'Overview';
|
|
242
242
|
|
|
243
|
+
if (process.env.__SSR_MD__) {
|
|
244
|
+
return (
|
|
245
|
+
<>
|
|
246
|
+
<FallbackHeading level={1} title={overviewTitle} />
|
|
247
|
+
{groups.map(group => (
|
|
248
|
+
<OverviewGroup key={group?.name} group={group} />
|
|
249
|
+
))}
|
|
250
|
+
</>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
243
254
|
return (
|
|
244
255
|
<div className="rspress-doc rp-doc rspress-overview rp-overview">
|
|
245
256
|
<FallbackHeading level={1} title={overviewTitle} />
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
import { Link, renderInlineMarkdown } from '@theme';
|
|
2
2
|
import './index.scss';
|
|
3
3
|
import type { Header } from '@rspress/core';
|
|
4
|
+
import { routePathToMdPath } from '@rspress/core/runtime';
|
|
4
5
|
import { FallbackHeading, SvgWrapper } from '@theme';
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
import IconPlugin from './icons/plugin.svg';
|
|
7
8
|
|
|
9
|
+
function OverviewGroupMarkdown({ group }: { group: Group }) {
|
|
10
|
+
const lines: string[] = [];
|
|
11
|
+
|
|
12
|
+
if (group.name) {
|
|
13
|
+
lines.push(`## ${group.name}`);
|
|
14
|
+
lines.push('');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (const item of group.items) {
|
|
18
|
+
const itemTitle = item.link
|
|
19
|
+
? `[${item.text}](${routePathToMdPath(item.link)})`
|
|
20
|
+
: `**${item.text}**`;
|
|
21
|
+
lines.push(`### ${itemTitle}`);
|
|
22
|
+
lines.push('');
|
|
23
|
+
|
|
24
|
+
// Render headers as a list
|
|
25
|
+
if (item.headers && item.headers.length > 0) {
|
|
26
|
+
for (const header of item.headers) {
|
|
27
|
+
const headerLink = item.link
|
|
28
|
+
? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})`
|
|
29
|
+
: header.text;
|
|
30
|
+
lines.push(`- ${headerLink}`);
|
|
31
|
+
}
|
|
32
|
+
lines.push('');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Render custom items as a list
|
|
36
|
+
if (item.items && item.items.length > 0) {
|
|
37
|
+
for (const subItem of item.items) {
|
|
38
|
+
const subItemLink = subItem.link
|
|
39
|
+
? `[${subItem.text}](${routePathToMdPath(subItem.link)})`
|
|
40
|
+
: subItem.text;
|
|
41
|
+
lines.push(`- ${subItemLink}`);
|
|
42
|
+
}
|
|
43
|
+
lines.push('');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return <>{lines.join('\n')}</>;
|
|
48
|
+
}
|
|
49
|
+
|
|
8
50
|
export interface GroupItem {
|
|
9
51
|
text: string;
|
|
10
52
|
link: string;
|
|
@@ -20,6 +62,10 @@ export interface Group {
|
|
|
20
62
|
}
|
|
21
63
|
|
|
22
64
|
export const OverviewGroup = ({ group }: { group: Group }) => {
|
|
65
|
+
if (process.env.__SSR_MD__) {
|
|
66
|
+
return <OverviewGroupMarkdown group={group} />;
|
|
67
|
+
}
|
|
68
|
+
|
|
23
69
|
const { itemsWithContent, itemsWithoutContent } = useMemo(() => {
|
|
24
70
|
// Separate items into those with content and those without
|
|
25
71
|
const itemsWithContent = group.items.filter(
|