@holdenmatt/md-schema 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Typed frontmatter schemas for markdown documents.
4
4
 
5
- `@holdenmatt/md-schema` parses YAML frontmatter with `gray-matter` and validates it with a Zod object schema. The markdown body is returned as trimmed markdown text.
5
+ `@holdenmatt/md-schema` parses Markdown with YAML frontmatter and validates the frontmatter with a Zod object schema. The markdown body is returned as trimmed markdown text.
6
6
 
7
7
  ## Install
8
8
 
@@ -48,7 +48,7 @@ Creates a parser for markdown documents with YAML frontmatter.
48
48
  - `frontmatterSchema`: a Zod object schema used to validate parsed frontmatter.
49
49
  - Returns `{ schema, parse }`.
50
50
  - `schema` is the original Zod schema.
51
- - `parse(markdown)` returns a safe result object and does not throw for YAML parse or Zod validation failures.
51
+ - `parse(markdown)` returns a safe result object and does not throw for parser or Zod validation failures.
52
52
 
53
53
  Success:
54
54
 
@@ -73,3 +73,5 @@ Failure:
73
73
  ```
74
74
 
75
75
  Only frontmatter is validated. The body is not parsed and is returned as trimmed markdown text.
76
+
77
+ Parsing is delegated to `@holdenmatt/md-parser`; `md-schema` is responsible for Zod validation and typed result shaping.
package/dist/index.d.ts CHANGED
@@ -34,6 +34,6 @@ export type MarkdownSchema<Schema extends FrontmatterSchema> = {
34
34
  /**
35
35
  * Create a parser for markdown documents with YAML frontmatter validated by a Zod object schema.
36
36
  *
37
- * YAML parse failures and Zod validation failures are returned as safe `{ success: false }` results.
37
+ * Markdown/frontmatter parse failures and Zod validation failures are returned as safe `{ success: false }` results.
38
38
  */
39
39
  export declare function markdownSchema<Schema extends FrontmatterSchema>(frontmatterSchema: Schema): MarkdownSchema<Schema>;
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import matter from "gray-matter";
1
+ import { parse as parseMarkdown } from "@holdenmatt/md-parser";
2
2
  /**
3
3
  * Create a parser for markdown documents with YAML frontmatter validated by a Zod object schema.
4
4
  *
5
- * YAML parse failures and Zod validation failures are returned as safe `{ success: false }` results.
5
+ * Markdown/frontmatter parse failures and Zod validation failures are returned as safe `{ success: false }` results.
6
6
  */
7
7
  export function markdownSchema(frontmatterSchema) {
8
8
  return {
9
9
  schema: frontmatterSchema,
10
10
  parse(markdown) {
11
- let file;
11
+ let document;
12
12
  try {
13
- file = matter(markdown);
13
+ document = parseMarkdown(markdown);
14
14
  }
15
15
  catch (error) {
16
16
  return { success: false, error };
17
17
  }
18
18
  try {
19
- const result = frontmatterSchema.safeParse(file.data);
19
+ const result = frontmatterSchema.safeParse(document.frontmatter);
20
20
  if (!result.success) {
21
21
  return { success: false, error: result.error };
22
22
  }
@@ -24,7 +24,7 @@ export function markdownSchema(frontmatterSchema) {
24
24
  success: true,
25
25
  data: {
26
26
  frontmatter: result.data,
27
- body: file.content.trim(),
27
+ body: document.body.trim(),
28
28
  markdown,
29
29
  },
30
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holdenmatt/md-schema",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Typed frontmatter schemas for markdown documents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "check": "pnpm format:check && pnpm lint && pnpm test && pnpm build"
29
29
  },
30
30
  "dependencies": {
31
- "gray-matter": "^4.0.3"
31
+ "@holdenmatt/md-parser": "^0.7.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^26.0.1",