@jk2908/mdsrc 0.4.0 → 0.4.1

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 (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +46 -22
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1 - 2026-06-23
4
+
5
+ - Updated README to reflect the new schema API and removed outdated markdown-it references.
6
+
3
7
  ## 0.4.0 - 2026-06-23
4
8
 
5
9
  - Breaking: replaced the verbose schema API with a simplified string-based syntax. Fields are now declared as `fieldName: 'type'` instead of `fieldName: { type: 'type' }`, optional fields use a `?` suffix (e.g. `'metadata?'`), and nested objects are declared inline without a `schema` wrapper.
package/README.md CHANGED
@@ -11,27 +11,19 @@ npm install @jk2908/mdsrc
11
11
  ## Usage
12
12
 
13
13
  ```ts
14
- import plugin, { type MarkdownItConfig } from '@jk2908/mdsrc'
15
- import comark from '@comark/markdown-it'
14
+ import plugin from '@jk2908/mdsrc'
16
15
  import { defineConfig } from 'vite'
17
16
 
18
- const markdownItConfig: MarkdownItConfig = {
19
- linkify: true,
20
- }
21
-
22
17
  export default defineConfig({
23
18
  plugins: [
24
19
  plugin({
25
- markdown: {
26
- plugins: [comark],
27
- config: markdownItConfig,
28
- },
29
20
  collections: [
30
21
  {
31
22
  dir: 'content',
32
23
  name: 'post',
33
24
  schema: {
34
- title: { type: 'string' },
25
+ title: 'string',
26
+ 'date?': 'date',
35
27
  },
36
28
  },
37
29
  ],
@@ -40,18 +32,51 @@ export default defineConfig({
40
32
  })
41
33
  ```
42
34
 
43
- The plugin reads markdown content, validates frontmatter against your schema, and generates typed modules during build and watch. Root config uses `collections`, optional `markdown`, and `logger`. Collection config uses `name`, `dir`, and `schema`.
35
+ The plugin reads markdown content, validates frontmatter against your schema, and generates typed modules during build and watch. Root config uses `collections`, optional `compileOptions`, and `logger`. Collection config uses `name`, `dir`, and `schema`.
36
+
37
+ ### Schema
38
+
39
+ Fields are declared as `fieldName: 'type'`. Supported types: `string`, `number`, `boolean`, `date`, `object`.
44
40
 
45
- Each entry exports both `html` and `markdown`.
41
+ Optional fields use a `?` suffix: `'metadata?': { author: 'string' }`.
42
+
43
+ Nested objects are declared inline:
44
+
45
+ ```ts
46
+ schema: {
47
+ title: 'string',
48
+ 'metadata?': {
49
+ author: 'string',
50
+ publishedAt: 'date',
51
+ },
52
+ }
53
+ ```
54
+
55
+ ### Compile Options
56
+
57
+ Pass `compileOptions` to customise markdown parsing via satteri:
58
+
59
+ ```ts
60
+ plugin({
61
+ compileOptions: {
62
+ features: {
63
+ gfm: true, // tables, footnotes, strikethrough, task lists
64
+ frontmatter: true, // YAML (---) and TOML (+++)
65
+ math: false, // LaTeX math blocks
66
+ smartPunctuation: true, // curly quotes, em-dashes, ellipses
67
+ },
68
+ mdastPlugins: [/* transform mdast tree */],
69
+ hastPlugins: [/* transform hast tree */],
70
+ },
71
+ collections: [/* ... */],
72
+ })
73
+ ```
46
74
 
47
- - `html` is rendered with `markdown-it-ts`, with hard line breaks preserved by default.
48
- - Raw HTML is escaped by default because the renderer runs with `html: false`.
49
- - `markdown` preserves the original body for custom renderers like `@comark/react`.
75
+ See [satteri](https://satteri.bruits.org/) for the full list of compile options and feature toggles.
50
76
 
51
- Use `markdown.plugins` for `markdown-it-ts` compatible plugins, and `markdown.config` to pass renderer options.
52
- `MarkdownItConfig` is re-exported from `@jk2908/mdsrc`, and `markdown.config` is merged with the default renderer options `{ html: false, breaks: true }`.
77
+ ### Output
53
78
 
54
- See `examples/basic` for the default HTML output flow and `examples/components` for the shared `@comark/markdown-it` plugin used with React.
79
+ Each entry exports a `body` field containing the rendered HTML.
55
80
 
56
81
  If you configure a collection with `name: 'post'`, `mdsrc` exposes `allPosts` from the package root.
57
82
 
@@ -61,8 +86,7 @@ import { allPosts } from '@jk2908/mdsrc'
61
86
  export const summaries = allPosts.map(post => ({
62
87
  title: post.title,
63
88
  slug: post.__mdsrc.slug,
64
- html: post.html,
65
- markdown: post.markdown,
89
+ body: post.body,
66
90
  }))
67
91
  ```
68
92
 
@@ -76,4 +100,4 @@ The generated files live in `./.mdsrc` on disk, so you can import them directly
76
100
 
77
101
  ## License
78
102
 
79
- MIT
103
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jk2908/mdsrc",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "author": "Jerome Kenway",
6
6
  "description": "A Vite plugin for turning structured Markdown content into importable, type-safe modules",