@rspress/shared 1.23.1 → 1.24.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.d.ts CHANGED
@@ -309,6 +309,7 @@ interface SidebarGroup {
309
309
  */
310
310
  _fileKey?: string;
311
311
  overviewHeaders?: number[];
312
+ context?: string;
312
313
  }
313
314
  type SidebarItem = {
314
315
  text: string;
@@ -319,6 +320,7 @@ type SidebarItem = {
319
320
  */
320
321
  _fileKey?: string;
321
322
  overviewHeaders?: number[];
323
+ context?: string;
322
324
  };
323
325
  type SidebarDivider = {
324
326
  dividerType: 'dashed' | 'solid';
@@ -454,7 +456,7 @@ interface UserConfig<ThemeConfig = Config$1> {
454
456
  /**
455
457
  * Head tags.
456
458
  */
457
- head?: string[];
459
+ head?: (string | [string, Record<string, string>] | ((route: RouteMeta) => string | [string, Record<string, string>] | undefined))[];
458
460
  /**
459
461
  * I18n config of the site.
460
462
  */
@@ -638,6 +640,9 @@ interface FrontMatterMeta {
638
640
  lineNumbers?: boolean;
639
641
  overviewHeaders?: number;
640
642
  titleSuffix?: string;
643
+ head?: [string, Record<string, string>][];
644
+ context?: string;
645
+ [key: string]: unknown;
641
646
  }
642
647
  interface PageData {
643
648
  siteData: SiteData<Config$1>;
@@ -1,5 +1,5 @@
1
- declare function loadFrontMatter(source: string, filepath: string, root: string, outputWarning?: boolean): {
2
- frontmatter: Record<string, string>;
1
+ declare function loadFrontMatter<TFrontmatter extends Record<string, unknown> = Record<string, string>>(source: string, filepath: string, root: string, outputWarning?: boolean): {
2
+ frontmatter: TFrontmatter;
3
3
  content: string;
4
4
  };
5
5
 
@@ -35,7 +35,7 @@ __export(node_utils_exports, {
35
35
  module.exports = __toCommonJS(node_utils_exports);
36
36
 
37
37
  // src/node-utils/loadFrontMatter.ts
38
- var import_path = __toESM(require("path"));
38
+ var import_node_path = __toESM(require("path"));
39
39
  var import_gray_matter = __toESM(require("gray-matter"));
40
40
 
41
41
  // src/logger.ts
@@ -43,21 +43,20 @@ var import_core = require("@rsbuild/core");
43
43
 
44
44
  // src/node-utils/loadFrontMatter.ts
45
45
  function loadFrontMatter(source, filepath, root, outputWarning = false) {
46
- let content = "";
47
- let frontmatter = {};
48
46
  try {
49
- ({ content, data: frontmatter } = (0, import_gray_matter.default)(source));
47
+ const { content, data } = (0, import_gray_matter.default)(source);
48
+ return { content, frontmatter: data };
50
49
  } catch (e) {
51
50
  if (outputWarning) {
52
51
  import_core.logger.warn(
53
- `Parse frontmatter error: ${e.message} in ${import_path.default.relative(
52
+ `Parse frontmatter error: ${e.message} in ${import_node_path.default.relative(
54
53
  root,
55
54
  filepath
56
55
  )}`
57
56
  );
58
57
  }
59
58
  }
60
- return { frontmatter, content };
59
+ return { content: "", frontmatter: {} };
61
60
  }
62
61
  // Annotate the CommonJS export names for ESM import in node:
63
62
  0 && (module.exports = {
@@ -7,10 +7,9 @@ import { logger } from "@rsbuild/core";
7
7
 
8
8
  // src/node-utils/loadFrontMatter.ts
9
9
  function loadFrontMatter(source, filepath, root, outputWarning = false) {
10
- let content = "";
11
- let frontmatter = {};
12
10
  try {
13
- ({ content, data: frontmatter } = grayMatter(source));
11
+ const { content, data } = grayMatter(source);
12
+ return { content, frontmatter: data };
14
13
  } catch (e) {
15
14
  if (outputWarning) {
16
15
  logger.warn(
@@ -21,7 +20,7 @@ function loadFrontMatter(source, filepath, root, outputWarning = false) {
21
20
  );
22
21
  }
23
22
  }
24
- return { frontmatter, content };
23
+ return { content: "", frontmatter: {} };
25
24
  }
26
25
  export {
27
26
  loadFrontMatter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",