@rspress/core 1.6.1 → 1.7.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/loader.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Rspack } from '@rsbuild/core/rspack-provider';
1
+ import { Rspack } from '@rsbuild/core';
2
2
  import * as _rspress_shared from '@rspress/shared';
3
3
  import { UserConfig, RspressPlugin, PageIndexInfo, RouteMeta } from '@rspress/shared';
4
4
 
@@ -56,6 +56,7 @@ interface LoaderOptions {
56
56
  interface PageMeta {
57
57
  toc: TocItem[];
58
58
  title: string;
59
+ frontmatter?: Record<string, any>;
59
60
  }
60
61
  declare function mdxLoader(context: Rspack.LoaderContext<LoaderOptions>, source: string, callback: Rspack.LoaderContext['callback']): Promise<void>;
61
62
 
package/dist/loader.js CHANGED
@@ -4014,7 +4014,7 @@ async function mdxLoader(context, source, callback) {
4014
4014
  docDirectory,
4015
4015
  true
4016
4016
  );
4017
- const hasFrontMatter = Object.keys(frontmatter).length > 0;
4017
+ const isHomePage = frontmatter.pageType === "home";
4018
4018
  try {
4019
4019
  let compileResult;
4020
4020
  if (!enableMdxRs) {
@@ -4037,7 +4037,8 @@ async function mdxLoader(context, source, callback) {
4037
4037
  });
4038
4038
  compileResult = String(vFile);
4039
4039
  pageMeta = {
4040
- ...compiler.data("pageMeta")
4040
+ ...compiler.data("pageMeta"),
4041
+ frontmatter
4041
4042
  };
4042
4043
  } else {
4043
4044
  const { compile } = __require("@rspress/mdx-rs");
@@ -4050,7 +4051,8 @@ async function mdxLoader(context, source, callback) {
4050
4051
  compileResult = code;
4051
4052
  pageMeta = {
4052
4053
  toc,
4053
- title
4054
+ title,
4055
+ frontmatter
4054
4056
  };
4055
4057
  if (checkDeadLinks) {
4056
4058
  checkLinks(links, filepath, docDirectory, routeService);
@@ -4061,7 +4063,8 @@ MDXContent.__RSPRESS_PAGE_META = {};
4061
4063
  MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(
4062
4064
  normalizePath(path7.relative(docDirectory, filepath))
4063
4065
  )}"] = ${JSON.stringify(pageMeta)};
4064
- ${hasFrontMatter ? `export const frontmatter = ${JSON.stringify(frontmatter)};` : ""}
4066
+ ${// Fix the home page won't update when the frontmatter is changed
4067
+ isHomePage ? `export const frontmatter = ${JSON.stringify(frontmatter)};` : ""}
4065
4068
 
4066
4069
  `;
4067
4070
  callback(null, result);