@md-plugins/md-plugin-frontmatter 0.1.0-alpha.1 → 0.1.0-alpha.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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +2 -1
- package/package.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2024-present,
|
|
3
|
+
Copyright (c) 2024-present, MD-PLUGINS
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ The `md-plugin-frontmatter` plugin supports the following options:
|
|
|
79
79
|
| Option | Type | Default | Description |
|
|
80
80
|
| ----------------- | ------- | ------- | ---------------------------------------------------------------------------------------------- |
|
|
81
81
|
| grayMatterOptions | object | {} | Options for the gray-matter library. Refer to the gray-matter documentation. |
|
|
82
|
-
| renderExcerpt | boolean |
|
|
82
|
+
| renderExcerpt | boolean | false | Whether to render the excerpt as HTML. If false, the raw Markdown is extracted as the excerpt. |
|
|
83
83
|
|
|
84
84
|
## Advanced Usage
|
|
85
85
|
|
|
@@ -92,7 +92,7 @@ md.use(frontmatterPlugin, {
|
|
|
92
92
|
grayMatterOptions: {
|
|
93
93
|
delimiters: '+++', // Use "+++" as the frontmatter delimiter
|
|
94
94
|
},
|
|
95
|
-
})
|
|
95
|
+
})
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
## Testing
|
package/dist/index.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ interface FrontmatterPluginOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Render the excerpt or not
|
|
17
17
|
*
|
|
18
|
-
* @default
|
|
18
|
+
* @default false
|
|
19
19
|
*/
|
|
20
20
|
renderExcerpt?: boolean;
|
|
21
21
|
}
|
|
@@ -25,6 +25,10 @@ declare module '@md-plugins/shared' {
|
|
|
25
25
|
* The raw Markdown content without frontmatter
|
|
26
26
|
*/
|
|
27
27
|
content?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether render excerpt or not
|
|
30
|
+
*/
|
|
31
|
+
renderExcerpt?: boolean;
|
|
28
32
|
/**
|
|
29
33
|
* The excerpt that extracted by `md-plugin-frontmatter`
|
|
30
34
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface FrontmatterPluginOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Render the excerpt or not
|
|
17
17
|
*
|
|
18
|
-
* @default
|
|
18
|
+
* @default false
|
|
19
19
|
*/
|
|
20
20
|
renderExcerpt?: boolean;
|
|
21
21
|
}
|
|
@@ -25,6 +25,10 @@ declare module '@md-plugins/shared' {
|
|
|
25
25
|
* The raw Markdown content without frontmatter
|
|
26
26
|
*/
|
|
27
27
|
content?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether render excerpt or not
|
|
30
|
+
*/
|
|
31
|
+
renderExcerpt?: boolean;
|
|
28
32
|
/**
|
|
29
33
|
* The excerpt that extracted by `md-plugin-frontmatter`
|
|
30
34
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import grayMatter from 'gray-matter';
|
|
2
2
|
|
|
3
|
-
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt =
|
|
3
|
+
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt = false } = {}) => {
|
|
4
4
|
const render = md.render.bind(md);
|
|
5
5
|
md.render = (src, env = {}) => {
|
|
6
6
|
let data, content, excerpt;
|
|
7
7
|
try {
|
|
8
|
+
;
|
|
8
9
|
({ data, content } = grayMatter(src, grayMatterOptions));
|
|
9
10
|
} catch (error) {
|
|
10
11
|
console.error("Failed to parse frontmatter:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/md-plugin-frontmatter",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "A markdown-it plugin for handling frontmatter in markdown files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"@types/markdown-it": "^14.1.2",
|
|
37
37
|
"gray-matter": "^4.0.3",
|
|
38
38
|
"markdown-it": "^14.1.0",
|
|
39
|
-
"@md-plugins/shared": "0.1.0-alpha.
|
|
39
|
+
"@md-plugins/shared": "0.1.0-alpha.2"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild",
|
|
46
|
-
"clean": "rm -rf dist",
|
|
46
|
+
"clean": "rm -rf dist/ node_modules/",
|
|
47
47
|
"test": "vitest"
|
|
48
48
|
}
|
|
49
49
|
}
|