@rspress/shared 1.8.4 → 1.9.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
@@ -621,7 +621,7 @@ interface SearchHooks {
621
621
  searchHooks?: string;
622
622
  }
623
623
  type LocalSearchOptions = SearchHooks & {
624
- mode: 'local';
624
+ mode?: 'local';
625
625
  };
626
626
  type RemoteSearchIndexInfo = string | {
627
627
  value: string;
package/dist/index.js CHANGED
@@ -1111,7 +1111,7 @@ function isUndefined(value) {
1111
1111
  }
1112
1112
  var isUndefined_default = isUndefined;
1113
1113
 
1114
- // src/utils/index.ts
1114
+ // src/runtime-utils/index.ts
1115
1115
  var QUERY_REGEXP = /\?.*$/s;
1116
1116
  var HASH_REGEXP = /#.*$/s;
1117
1117
  var MDX_REGEXP = /\.mdx?$/;
package/dist/index.mjs CHANGED
@@ -1053,7 +1053,7 @@ function isUndefined(value) {
1053
1053
  }
1054
1054
  var isUndefined_default = isUndefined;
1055
1055
 
1056
- // src/utils/index.ts
1056
+ // src/runtime-utils/index.ts
1057
1057
  var QUERY_REGEXP = /\?.*$/s;
1058
1058
  var HASH_REGEXP = /#.*$/s;
1059
1059
  var MDX_REGEXP = /\.mdx?$/;
@@ -0,0 +1,6 @@
1
+ declare function loadFrontMatter(source: string, filepath: string, root: string, outputWarning?: boolean): {
2
+ frontmatter: Record<string, string>;
3
+ content: string;
4
+ };
5
+
6
+ export { loadFrontMatter };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/node-utils.ts
31
+ var node_utils_exports = {};
32
+ __export(node_utils_exports, {
33
+ loadFrontMatter: () => loadFrontMatter
34
+ });
35
+ module.exports = __toCommonJS(node_utils_exports);
36
+
37
+ // src/node-utils/loadFrontMatter.ts
38
+ var import_path = __toESM(require("path"));
39
+ var import_gray_matter = __toESM(require("gray-matter"));
40
+
41
+ // src/logger.ts
42
+ var import_rslog = require("rslog");
43
+
44
+ // src/node-utils/loadFrontMatter.ts
45
+ function loadFrontMatter(source, filepath, root, outputWarning = false) {
46
+ let frontmatter = {};
47
+ let content = "";
48
+ try {
49
+ ({ data: frontmatter, content } = (0, import_gray_matter.default)(source));
50
+ } catch (e) {
51
+ if (outputWarning) {
52
+ import_rslog.logger.warn(
53
+ `Parse frontmatter error: ${e.message} in ${import_path.default.relative(
54
+ root,
55
+ filepath
56
+ )}`
57
+ );
58
+ }
59
+ }
60
+ return { frontmatter, content };
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ loadFrontMatter
65
+ });
@@ -0,0 +1,28 @@
1
+ // src/node-utils/loadFrontMatter.ts
2
+ import path from "path";
3
+ import grayMatter from "gray-matter";
4
+
5
+ // src/logger.ts
6
+ import { logger } from "rslog";
7
+
8
+ // src/node-utils/loadFrontMatter.ts
9
+ function loadFrontMatter(source, filepath, root, outputWarning = false) {
10
+ let frontmatter = {};
11
+ let content = "";
12
+ try {
13
+ ({ data: frontmatter, content } = grayMatter(source));
14
+ } catch (e) {
15
+ if (outputWarning) {
16
+ logger.warn(
17
+ `Parse frontmatter error: ${e.message} in ${path.relative(
18
+ root,
19
+ filepath
20
+ )}`
21
+ );
22
+ }
23
+ }
24
+ return { frontmatter, content };
25
+ }
26
+ export {
27
+ loadFrontMatter
28
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "1.8.4",
3
+ "version": "1.9.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -34,6 +34,11 @@
34
34
  "import": "./dist/logger.mjs",
35
35
  "require": "./dist/logger.js",
36
36
  "types": "./dist/logger.d.ts"
37
+ },
38
+ "./node-utils": {
39
+ "import": "./dist/node-utils.mjs",
40
+ "require": "./dist/node-utils.js",
41
+ "types": "./dist/node-utils.d.ts"
37
42
  }
38
43
  },
39
44
  "dependencies": {
@@ -42,7 +47,8 @@
42
47
  "chalk": "4.1.2",
43
48
  "rslog": "^1.1.0",
44
49
  "execa": "5.1.1",
45
- "fs-extra": "11.2.0"
50
+ "fs-extra": "11.2.0",
51
+ "gray-matter": "4.0.3"
46
52
  },
47
53
  "devDependencies": {
48
54
  "lodash-es": "^4.17.21",