@rspress/core 1.0.2 → 1.1.0
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/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +24 -105
- package/dist/loader.js.map +1 -1
- package/dist/theme/bundle.css +291 -293
- package/dist/theme/bundle.d.ts +1 -1
- package/dist/theme/bundle.js +567 -511
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +14 -14
- package/src/theme-default/components/HomeHero/index.tsx +5 -4
- package/src/theme-default/components/Nav/NavBarTitle.tsx +2 -1
- package/src/theme-default/components/Nav/NavMenuGroup.tsx +1 -14
- package/src/theme-default/components/Nav/NavTranslations.tsx +16 -0
- package/src/theme-default/components/Nav/NavVersions.tsx +16 -0
- package/src/theme-default/components/Nav/index.tsx +12 -50
- package/src/theme-default/components/Nav/menuDataHooks.tsx +75 -0
- package/src/theme-default/components/{NavScreenMenuGroup → NavScreen}/NavScreenMenuGroup.tsx +1 -1
- package/src/theme-default/components/NavScreen/index.module.scss +42 -0
- package/src/theme-default/components/NavScreen/index.tsx +26 -54
- package/src/theme-default/components/Overview/index.module.scss +4 -5
- package/src/theme-default/components/Overview/index.tsx +7 -2
- package/src/theme-default/components/Search/index.module.scss +2 -0
- package/src/theme-default/components/Search/index.tsx +11 -3
- package/src/theme-default/components/Sidebar/index.tsx +1 -1
- package/src/theme-default/components/SocialLinks/HiddenLinks.tsx +1 -1
- package/src/theme-default/components/SocialLinks/ShownLinks.tsx +1 -1
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +4 -27
- package/src/theme-default/layout/DocLayout/index.module.scss +1 -0
- package/src/theme-default/layout/DocLayout/index.tsx +15 -5
- package/src/theme-default/layout/Layout/index.tsx +25 -1
- package/src/theme-default/logic/useHiddenNav.ts +4 -1
- package/src/theme-default/components/NavScreenMenuGroup/index.module.scss +0 -41
package/dist/loader.js
CHANGED
|
@@ -3479,7 +3479,7 @@ var require_parse = __commonJS({
|
|
|
3479
3479
|
var require_gray_matter = __commonJS({
|
|
3480
3480
|
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/index.js"(exports2, module2) {
|
|
3481
3481
|
"use strict";
|
|
3482
|
-
var
|
|
3482
|
+
var fs = __require("fs");
|
|
3483
3483
|
var sections = require_section_matter();
|
|
3484
3484
|
var defaults = require_defaults();
|
|
3485
3485
|
var stringify = require_stringify();
|
|
@@ -3564,7 +3564,7 @@ var require_gray_matter = __commonJS({
|
|
|
3564
3564
|
return stringify(file, data, options2);
|
|
3565
3565
|
};
|
|
3566
3566
|
matter.read = function(filepath, options2) {
|
|
3567
|
-
const str2 =
|
|
3567
|
+
const str2 = fs.readFileSync(filepath, "utf8");
|
|
3568
3568
|
const file = matter(str2, options2);
|
|
3569
3569
|
file.path = filepath;
|
|
3570
3570
|
return file;
|
|
@@ -3594,8 +3594,8 @@ var require_gray_matter = __commonJS({
|
|
|
3594
3594
|
|
|
3595
3595
|
// src/node/mdx/loader.ts
|
|
3596
3596
|
var import_gray_matter = __toESM(require_gray_matter());
|
|
3597
|
-
import
|
|
3598
|
-
import { createProcessor
|
|
3597
|
+
import path6 from "path";
|
|
3598
|
+
import { createProcessor } from "@mdx-js/mdx";
|
|
3599
3599
|
|
|
3600
3600
|
// src/node/utils/normalizePath.ts
|
|
3601
3601
|
import os from "os";
|
|
@@ -3608,47 +3608,8 @@ function normalizePath(id) {
|
|
|
3608
3608
|
return path.posix.normalize(isWindows ? slash(id) : id);
|
|
3609
3609
|
}
|
|
3610
3610
|
|
|
3611
|
-
// src/node/utils/getPageKey.ts
|
|
3612
|
-
import { removeLeadingSlash } from "@rspress/shared";
|
|
3613
|
-
|
|
3614
|
-
// src/node/utils/createHash.ts
|
|
3615
|
-
import { createHash as createHashFunc } from "crypto";
|
|
3616
|
-
|
|
3617
|
-
// src/node/utils/detectReactVersion.ts
|
|
3618
|
-
import path3 from "path";
|
|
3619
|
-
import fs from "@modern-js/utils/fs-extra";
|
|
3620
|
-
import { logger } from "@rspress/shared/logger";
|
|
3621
|
-
import enhancedResolve from "enhanced-resolve";
|
|
3622
|
-
|
|
3623
|
-
// src/node/constants.ts
|
|
3624
|
-
import path2 from "path";
|
|
3625
|
-
import { fileURLToPath } from "url";
|
|
3626
|
-
import { RSPRESS_TEMP_DIR } from "@rspress/shared";
|
|
3627
|
-
var dirname = path2.dirname(fileURLToPath(new URL(import.meta.url)));
|
|
3628
|
-
var PACKAGE_ROOT = path2.join(dirname, "..");
|
|
3629
|
-
var CLIENT_ENTRY = path2.join(
|
|
3630
|
-
PACKAGE_ROOT,
|
|
3631
|
-
"dist",
|
|
3632
|
-
"runtime",
|
|
3633
|
-
"clientEntry.js"
|
|
3634
|
-
);
|
|
3635
|
-
var SSR_ENTRY = path2.join(
|
|
3636
|
-
PACKAGE_ROOT,
|
|
3637
|
-
"dist",
|
|
3638
|
-
"runtime",
|
|
3639
|
-
"ssrEntry.js"
|
|
3640
|
-
);
|
|
3641
|
-
var TEMP_DIR = path2.join(
|
|
3642
|
-
process.cwd(),
|
|
3643
|
-
"node_modules",
|
|
3644
|
-
RSPRESS_TEMP_DIR
|
|
3645
|
-
);
|
|
3646
|
-
|
|
3647
|
-
// src/node/utils/detectReactVersion.ts
|
|
3648
|
-
var { CachedInputFileSystem, ResolverFactory } = enhancedResolve;
|
|
3649
|
-
|
|
3650
3611
|
// src/node/mdx/options.ts
|
|
3651
|
-
import
|
|
3612
|
+
import path5 from "path";
|
|
3652
3613
|
import remarkGFM from "remark-gfm";
|
|
3653
3614
|
import rehypeSlug from "rehype-slug";
|
|
3654
3615
|
import rehypeAutoLink from "rehype-autolink-headings";
|
|
@@ -3712,7 +3673,7 @@ var rehypePluginCodeMeta = () => {
|
|
|
3712
3673
|
};
|
|
3713
3674
|
|
|
3714
3675
|
// src/node/mdx/remarkPlugins/normalizeLink.ts
|
|
3715
|
-
import
|
|
3676
|
+
import path2 from "path";
|
|
3716
3677
|
import { visit as visit2 } from "unist-util-visit";
|
|
3717
3678
|
import { normalizeHref, parseUrl, isExternalUrl, slash as slash2 } from "@rspress/shared";
|
|
3718
3679
|
|
|
@@ -3763,19 +3724,19 @@ var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
|
|
|
3763
3724
|
node.url = url + (hash ? `#${hash}` : "");
|
|
3764
3725
|
return;
|
|
3765
3726
|
}
|
|
3766
|
-
const extname =
|
|
3727
|
+
const extname = path2.extname(url);
|
|
3767
3728
|
if (extname === ".md" || extname === ".mdx") {
|
|
3768
3729
|
url = url.replace(extname, "");
|
|
3769
3730
|
}
|
|
3770
|
-
const relativePath =
|
|
3731
|
+
const relativePath = path2.relative(root, file.path);
|
|
3771
3732
|
if (url.startsWith(".")) {
|
|
3772
|
-
url =
|
|
3733
|
+
url = path2.posix.join(slash2(path2.dirname(relativePath)), url);
|
|
3773
3734
|
}
|
|
3774
3735
|
url = normalizeHref(url, cleanUrls);
|
|
3775
3736
|
if (hash) {
|
|
3776
3737
|
url += `#${hash}`;
|
|
3777
3738
|
}
|
|
3778
|
-
node.url =
|
|
3739
|
+
node.url = path2.posix.join(base, url);
|
|
3779
3740
|
}
|
|
3780
3741
|
);
|
|
3781
3742
|
const normalizeImageUrl = (imageUrl) => {
|
|
@@ -3854,67 +3815,25 @@ var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
|
|
|
3854
3815
|
};
|
|
3855
3816
|
|
|
3856
3817
|
// src/node/mdx/remarkPlugins/checkDeadLink.ts
|
|
3857
|
-
import
|
|
3818
|
+
import path3 from "path";
|
|
3858
3819
|
import { visit as visit3 } from "unist-util-visit";
|
|
3859
3820
|
import logUtils from "@modern-js/utils/logger";
|
|
3860
3821
|
import { cleanUrl, isProduction } from "@rspress/shared";
|
|
3861
3822
|
|
|
3862
3823
|
// src/node/runtimeModule/routeData.ts
|
|
3863
|
-
import { addLeadingSlash
|
|
3864
|
-
|
|
3865
|
-
// src/node/runtimeModule/index.ts
|
|
3866
|
-
import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
|
|
3867
|
-
|
|
3868
|
-
// src/node/runtimeModule/siteData.ts
|
|
3869
|
-
import path6 from "path";
|
|
3870
|
-
import {
|
|
3871
|
-
withBase,
|
|
3872
|
-
MDX_REGEXP as MDX_REGEXP2,
|
|
3873
|
-
SEARCH_INDEX_NAME,
|
|
3874
|
-
addLeadingSlash,
|
|
3875
|
-
isExternalUrl as isExternalUrl2,
|
|
3876
|
-
withoutBase
|
|
3877
|
-
} from "@rspress/shared";
|
|
3878
|
-
import yamlFrontMatter from "yaml-front-matter";
|
|
3879
|
-
import { htmlToText } from "html-to-text";
|
|
3880
|
-
import fs3 from "@modern-js/utils/fs-extra";
|
|
3881
|
-
import { compile } from "@rspress/mdx-rs";
|
|
3882
|
-
|
|
3883
|
-
// src/node/utils/flattenMdxContent.ts
|
|
3884
|
-
import path5 from "path";
|
|
3885
|
-
import enhancedResolve2 from "enhanced-resolve";
|
|
3886
|
-
import fs2 from "@modern-js/utils/fs-extra";
|
|
3887
|
-
import { createProcessor } from "@mdx-js/mdx";
|
|
3888
|
-
import { MDX_REGEXP } from "@rspress/shared";
|
|
3889
|
-
var { CachedInputFileSystem: CachedInputFileSystem2, ResolverFactory: ResolverFactory2 } = enhancedResolve2;
|
|
3890
|
-
var processor = createProcessor();
|
|
3891
|
-
|
|
3892
|
-
// src/node/runtimeModule/i18n.ts
|
|
3893
|
-
import { join } from "path";
|
|
3894
|
-
var DEFAULT_I18N_SOURCE = join(process.cwd(), "i18n.json");
|
|
3895
|
-
|
|
3896
|
-
// src/node/runtimeModule/siteData.ts
|
|
3897
|
-
var { loadFront } = yamlFrontMatter;
|
|
3898
|
-
|
|
3899
|
-
// src/node/runtimeModule/globalStyles.ts
|
|
3900
|
-
import fs4 from "@modern-js/utils/fs-extra";
|
|
3901
|
-
|
|
3902
|
-
// src/node/runtimeModule/searchHooks.ts
|
|
3903
|
-
import fs5 from "@modern-js/utils/fs-extra";
|
|
3904
|
-
|
|
3905
|
-
// src/node/runtimeModule/routeData.ts
|
|
3824
|
+
import { addLeadingSlash } from "@rspress/shared";
|
|
3906
3825
|
var normalizeRoutePath = (routePath) => {
|
|
3907
3826
|
const result = routePath.replace(/\.(.*)?$/, "").replace(/index$/, "");
|
|
3908
|
-
return
|
|
3827
|
+
return addLeadingSlash(result);
|
|
3909
3828
|
};
|
|
3910
3829
|
|
|
3911
3830
|
// src/node/mdx/remarkPlugins/checkDeadLink.ts
|
|
3912
|
-
var { logger
|
|
3831
|
+
var { logger } = logUtils;
|
|
3913
3832
|
var IGNORE_REGEXP = /^(https?|mailto|tel|#)/;
|
|
3914
3833
|
function checkLinks(links, filepath, root, routeService) {
|
|
3915
3834
|
const errorInfos = [];
|
|
3916
3835
|
links.filter((link) => !IGNORE_REGEXP.test(link)).map((link) => normalizePath(link)).forEach((link) => {
|
|
3917
|
-
const relativePath =
|
|
3836
|
+
const relativePath = path3.relative(root, filepath);
|
|
3918
3837
|
if (!routeService.isExistRoute(cleanUrl(link))) {
|
|
3919
3838
|
errorInfos.push(
|
|
3920
3839
|
`Internal link to ${link} is dead, check it in ${relativePath}`
|
|
@@ -3923,7 +3842,7 @@ function checkLinks(links, filepath, root, routeService) {
|
|
|
3923
3842
|
});
|
|
3924
3843
|
if (errorInfos.length > 0) {
|
|
3925
3844
|
errorInfos?.forEach((err) => {
|
|
3926
|
-
|
|
3845
|
+
logger.error(err);
|
|
3927
3846
|
});
|
|
3928
3847
|
if (isProduction()) {
|
|
3929
3848
|
throw new Error("Dead link found");
|
|
@@ -3945,7 +3864,7 @@ var remarkCheckDeadLinks = (checkLink) => {
|
|
|
3945
3864
|
if (!url.startsWith("http") && !url.startsWith("https")) {
|
|
3946
3865
|
const normalizeUrl = normalizeRoutePath(
|
|
3947
3866
|
// fix: windows path
|
|
3948
|
-
url?.split(
|
|
3867
|
+
url?.split(path3.sep).join("/")?.split("#")[0]
|
|
3949
3868
|
);
|
|
3950
3869
|
internalLinks.add(normalizeUrl);
|
|
3951
3870
|
}
|
|
@@ -3955,13 +3874,13 @@ var remarkCheckDeadLinks = (checkLink) => {
|
|
|
3955
3874
|
};
|
|
3956
3875
|
|
|
3957
3876
|
// src/node/mdx/remarkPlugins/builtin.ts
|
|
3958
|
-
import
|
|
3877
|
+
import path4 from "path";
|
|
3959
3878
|
var remarkBuiltin = ({
|
|
3960
3879
|
globalComponents
|
|
3961
3880
|
}) => {
|
|
3962
3881
|
return (tree) => {
|
|
3963
3882
|
const demos = globalComponents.map((componentPath) => {
|
|
3964
|
-
const filename =
|
|
3883
|
+
const filename = path4.parse(componentPath).name;
|
|
3965
3884
|
const componentName = filename[0].toUpperCase() + filename.slice(1);
|
|
3966
3885
|
return getASTNodeImport(componentName, componentPath);
|
|
3967
3886
|
});
|
|
@@ -3993,7 +3912,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
3993
3912
|
const defaultLang = config?.lang || "";
|
|
3994
3913
|
return {
|
|
3995
3914
|
providerImportSource: "@mdx-js/react",
|
|
3996
|
-
format:
|
|
3915
|
+
format: path5.extname(filepath).slice(1),
|
|
3997
3916
|
remarkPlugins: [
|
|
3998
3917
|
remarkGFM,
|
|
3999
3918
|
remarkPluginToc,
|
|
@@ -4082,7 +4001,7 @@ async function mdxLoader(context, source, callback) {
|
|
|
4082
4001
|
filepath,
|
|
4083
4002
|
pluginDriver
|
|
4084
4003
|
);
|
|
4085
|
-
const compiler =
|
|
4004
|
+
const compiler = createProcessor(mdxOptions);
|
|
4086
4005
|
compiler.data("pageMeta", {
|
|
4087
4006
|
toc: [],
|
|
4088
4007
|
title: ""
|
|
@@ -4096,8 +4015,8 @@ async function mdxLoader(context, source, callback) {
|
|
|
4096
4015
|
...compiler.data("pageMeta")
|
|
4097
4016
|
};
|
|
4098
4017
|
} else {
|
|
4099
|
-
const { compile
|
|
4100
|
-
const { toc, links, title, code } = await
|
|
4018
|
+
const { compile } = __require("@rspress/mdx-rs");
|
|
4019
|
+
const { toc, links, title, code } = await compile({
|
|
4101
4020
|
value: content,
|
|
4102
4021
|
filepath,
|
|
4103
4022
|
root: docDirectory,
|
|
@@ -4115,7 +4034,7 @@ async function mdxLoader(context, source, callback) {
|
|
|
4115
4034
|
const result = `${compileResult}
|
|
4116
4035
|
MDXContent.__RSPRESS_PAGE_META = {};
|
|
4117
4036
|
MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(
|
|
4118
|
-
normalizePath(
|
|
4037
|
+
normalizePath(path6.relative(docDirectory, filepath))
|
|
4119
4038
|
)}"] = ${JSON.stringify(pageMeta)};
|
|
4120
4039
|
${hasFrontMatter ? `export const frontmatter = ${JSON.stringify(frontmatter)};` : ""}
|
|
4121
4040
|
|