@rspress/core 0.2.0 → 1.0.0-beta.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 +6 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +0 -1
- package/dist/loader.js +14 -11
- package/dist/loader.js.map +1 -1
- package/dist/runtime/App.js +3 -4
- package/dist/runtime/Content.js +15 -8
- package/dist/runtime/hooks.d.ts +10 -0
- package/dist/runtime/hooks.js +6 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/utils.d.ts +3 -2
- package/dist/runtime/utils.js +6 -2
- package/dist/theme/bundle.css +5 -3
- package/dist/theme/bundle.js +44 -21
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +6 -6
- package/src/runtime/App.tsx +4 -6
- package/src/runtime/Content.tsx +24 -11
- package/src/runtime/global.d.ts +4 -5
- package/src/runtime/hooks.ts +22 -2
- package/src/runtime/index.ts +1 -1
- package/src/runtime/utils.ts +9 -8
- package/src/theme-default/components/DocFooter/index.tsx +1 -1
- package/src/theme-default/components/HomeHero/index.tsx +1 -1
- package/src/theme-default/components/Link/index.module.scss +0 -1
- package/src/theme-default/components/Link/index.tsx +21 -2
- package/src/theme-default/components/Nav/NavMenuSingleItem.tsx +1 -1
- package/src/theme-default/components/Overview/index.tsx +1 -1
- package/src/theme-default/components/Search/logic/search.ts +1 -1
- package/src/theme-default/components/Sidebar/SidebarGroup.tsx +1 -1
- package/src/theme-default/components/Sidebar/SidebarItem.tsx +1 -1
- package/src/theme-default/layout/DocLayout/docComponents/index.module.scss +4 -0
- package/src/theme-default/layout/DocLayout/docComponents/link.tsx +14 -8
- package/src/theme-default/layout/HomeLayout/index.tsx +1 -0
- package/src/theme-default/logic/sideEffects.ts +7 -0
- package/src/theme-default/logic/usePathUtils.ts +2 -1
package/dist/loader.js
CHANGED
|
@@ -3758,7 +3758,7 @@ var getASTNodeImport = (name, from) => ({
|
|
|
3758
3758
|
});
|
|
3759
3759
|
|
|
3760
3760
|
// src/node/mdx/remarkPlugins/normalizeLink.ts
|
|
3761
|
-
var remarkPluginNormalizeLink = ({ base, root }) => (tree, file) => {
|
|
3761
|
+
var remarkPluginNormalizeLink = ({ base, root, cleanUrls }) => (tree, file) => {
|
|
3762
3762
|
const images = [];
|
|
3763
3763
|
visit2(tree, (node) => node.type === "link", (node) => {
|
|
3764
3764
|
if (!node.url) {
|
|
@@ -3781,7 +3781,7 @@ var remarkPluginNormalizeLink = ({ base, root }) => (tree, file) => {
|
|
|
3781
3781
|
if (url.startsWith(".")) {
|
|
3782
3782
|
url = path2.posix.join(slash2(path2.dirname(relativePath)), url);
|
|
3783
3783
|
}
|
|
3784
|
-
url = normalizeHref(url);
|
|
3784
|
+
url = normalizeHref(url, cleanUrls);
|
|
3785
3785
|
if (hash) {
|
|
3786
3786
|
url += `#${hash}`;
|
|
3787
3787
|
}
|
|
@@ -3937,6 +3937,7 @@ var remarkBuiltin = ({ globalComponents }) => {
|
|
|
3937
3937
|
|
|
3938
3938
|
// src/node/mdx/options.ts
|
|
3939
3939
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
3940
|
+
const cleanUrls = Boolean(config?.route?.cleanUrls);
|
|
3940
3941
|
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = config?.markdown || {};
|
|
3941
3942
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
3942
3943
|
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin) => plugin.markdown?.remarkPlugins || []);
|
|
@@ -3956,6 +3957,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
3956
3957
|
remarkPluginNormalizeLink,
|
|
3957
3958
|
{
|
|
3958
3959
|
base: config?.base || "",
|
|
3960
|
+
cleanUrls,
|
|
3959
3961
|
defaultLang,
|
|
3960
3962
|
root: docDirectory
|
|
3961
3963
|
}
|
|
@@ -4013,11 +4015,11 @@ async function mdxLoader(context, source, callback) {
|
|
|
4013
4015
|
context.cacheable(true);
|
|
4014
4016
|
let pageMeta = {
|
|
4015
4017
|
title: "",
|
|
4016
|
-
toc: []
|
|
4017
|
-
frontmatter: {}
|
|
4018
|
+
toc: []
|
|
4018
4019
|
};
|
|
4019
4020
|
const { config, docDirectory, checkDeadLinks, routeService, enableMdxRs, pluginDriver } = options2;
|
|
4020
4021
|
const { data: frontmatter, content } = (0, import_gray_matter.default)(source);
|
|
4022
|
+
const hasFrontMatter = Object.keys(frontmatter).length > 0;
|
|
4021
4023
|
try {
|
|
4022
4024
|
let compileResult;
|
|
4023
4025
|
if (!enableMdxRs) {
|
|
@@ -4033,8 +4035,7 @@ async function mdxLoader(context, source, callback) {
|
|
|
4033
4035
|
});
|
|
4034
4036
|
compileResult = String(vFile);
|
|
4035
4037
|
pageMeta = {
|
|
4036
|
-
...compiler.data("pageMeta")
|
|
4037
|
-
frontmatter
|
|
4038
|
+
...compiler.data("pageMeta")
|
|
4038
4039
|
};
|
|
4039
4040
|
} else {
|
|
4040
4041
|
const { compile } = __require("@rspress/mdx-rs");
|
|
@@ -4047,16 +4048,18 @@ async function mdxLoader(context, source, callback) {
|
|
|
4047
4048
|
compileResult = code;
|
|
4048
4049
|
pageMeta = {
|
|
4049
4050
|
toc,
|
|
4050
|
-
title
|
|
4051
|
-
frontmatter
|
|
4051
|
+
title
|
|
4052
4052
|
};
|
|
4053
4053
|
if (checkDeadLinks) {
|
|
4054
4054
|
checkLinks(links, filepath, docDirectory, routeService);
|
|
4055
4055
|
}
|
|
4056
4056
|
}
|
|
4057
|
-
const result =
|
|
4058
|
-
|
|
4059
|
-
${
|
|
4057
|
+
const result = `${compileResult}
|
|
4058
|
+
MDXContent.__RSPRESS_PAGE_META = {};
|
|
4059
|
+
MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(path6.relative(docDirectory, filepath)))}"] = ${JSON.stringify(pageMeta)};
|
|
4060
|
+
${hasFrontMatter ? `export const frontmatter = ${JSON.stringify(frontmatter)};` : ""}
|
|
4061
|
+
|
|
4062
|
+
`;
|
|
4060
4063
|
callback(null, result);
|
|
4061
4064
|
} catch (e) {
|
|
4062
4065
|
console.error(`MDX compile error: ${e.message} in ${filepath}`);
|