fumadocs-mdx 8.2.20 → 8.2.22

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.
Files changed (2) hide show
  1. package/dist/index.mjs +23 -3
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -23,10 +23,26 @@ var defaultSchemas = {
23
23
  // src/resolve-files.ts
24
24
  var pageTypes = [".md", ".mdx"];
25
25
  var metaTypes = [".json"];
26
+ var DataError = class extends Error {
27
+ constructor(name, error) {
28
+ const info = error.flatten();
29
+ super(
30
+ `${name}: ${JSON.stringify(
31
+ {
32
+ root: info.formErrors,
33
+ ...info.fieldErrors
34
+ },
35
+ null,
36
+ 2
37
+ )}`
38
+ );
39
+ this.name = "DataError";
40
+ }
41
+ };
26
42
  function parse(schema, object, errorName) {
27
43
  const result = schema.safeParse(object);
28
44
  if (!result.success) {
29
- throw new Error(`Invalid ${errorName}: ${result.error.toString()}`);
45
+ throw new DataError(errorName, result.error);
30
46
  }
31
47
  return result.data;
32
48
  }
@@ -44,7 +60,11 @@ function resolveFiles({
44
60
  outputs.push({
45
61
  type: "meta",
46
62
  path: file,
47
- data: parse(schema.meta ?? defaultSchemas.meta, value, file)
63
+ data: parse(
64
+ schema.meta ?? defaultSchemas.meta,
65
+ value,
66
+ `Invalid meta file in ${file}`
67
+ )
48
68
  });
49
69
  continue;
50
70
  }
@@ -53,7 +73,7 @@ function resolveFiles({
53
73
  const parsedFrontmatter = parse(
54
74
  schema.frontmatter ?? defaultSchemas.frontmatter,
55
75
  frontmatter,
56
- file
76
+ `Invalid Frontmatter in ${file}`
57
77
  );
58
78
  outputs.push({
59
79
  type: "page",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "8.2.20",
3
+ "version": "8.2.22",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -43,7 +43,7 @@
43
43
  "fast-glob": "^3.3.1",
44
44
  "gray-matter": "^4.0.3",
45
45
  "zod": "^3.23.8",
46
- "fumadocs-core": "11.1.2"
46
+ "fumadocs-core": "11.2.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/cross-spawn": "^6.0.6",