@mdit-vue/plugin-frontmatter 0.12.0 → 1.0.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.cjs +5 -1
- package/dist/index.d.cts +49 -0
- package/dist/index.d.mts +49 -0
- package/dist/index.d.ts +1 -1
- package/package.json +12 -7
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const grayMatter = require('gray-matter');
|
|
4
4
|
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
6
|
+
|
|
7
|
+
const grayMatter__default = /*#__PURE__*/_interopDefaultCompat(grayMatter);
|
|
8
|
+
|
|
5
9
|
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt = true } = {}) => {
|
|
6
10
|
const render = md.render.bind(md);
|
|
7
11
|
md.render = (src, env = {}) => {
|
|
8
|
-
const { data, content, excerpt = "" } =
|
|
12
|
+
const { data, content, excerpt = "" } = grayMatter__default(src, grayMatterOptions);
|
|
9
13
|
env.content = content;
|
|
10
14
|
env.frontmatter = {
|
|
11
15
|
// allow providing default value
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import MarkdownIt from 'markdown-it';
|
|
2
|
+
import matter from 'gray-matter';
|
|
3
|
+
|
|
4
|
+
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
|
|
5
|
+
/**
|
|
6
|
+
* Options of @mdit-vue/plugin-frontmatter
|
|
7
|
+
*/
|
|
8
|
+
interface FrontmatterPluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Options of gray-matter
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
13
|
+
*/
|
|
14
|
+
grayMatterOptions?: GrayMatterOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Render the excerpt or not
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
renderExcerpt?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare module '@mdit-vue/types' {
|
|
23
|
+
interface MarkdownItEnv {
|
|
24
|
+
/**
|
|
25
|
+
* The raw Markdown content without frontmatter
|
|
26
|
+
*/
|
|
27
|
+
content?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
|
30
|
+
*
|
|
31
|
+
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
|
32
|
+
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
|
33
|
+
*/
|
|
34
|
+
excerpt?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
|
37
|
+
*/
|
|
38
|
+
frontmatter?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get markdown frontmatter and excerpt
|
|
44
|
+
*
|
|
45
|
+
* Extract them into env
|
|
46
|
+
*/
|
|
47
|
+
declare const frontmatterPlugin: MarkdownIt.PluginWithOptions<FrontmatterPluginOptions>;
|
|
48
|
+
|
|
49
|
+
export { type FrontmatterPluginOptions, frontmatterPlugin };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import MarkdownIt from 'markdown-it';
|
|
2
|
+
import matter from 'gray-matter';
|
|
3
|
+
|
|
4
|
+
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
|
|
5
|
+
/**
|
|
6
|
+
* Options of @mdit-vue/plugin-frontmatter
|
|
7
|
+
*/
|
|
8
|
+
interface FrontmatterPluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Options of gray-matter
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
13
|
+
*/
|
|
14
|
+
grayMatterOptions?: GrayMatterOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Render the excerpt or not
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
renderExcerpt?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare module '@mdit-vue/types' {
|
|
23
|
+
interface MarkdownItEnv {
|
|
24
|
+
/**
|
|
25
|
+
* The raw Markdown content without frontmatter
|
|
26
|
+
*/
|
|
27
|
+
content?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
|
30
|
+
*
|
|
31
|
+
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
|
32
|
+
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
|
33
|
+
*/
|
|
34
|
+
excerpt?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
|
37
|
+
*/
|
|
38
|
+
frontmatter?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get markdown frontmatter and excerpt
|
|
44
|
+
*
|
|
45
|
+
* Extract them into env
|
|
46
|
+
*/
|
|
47
|
+
declare const frontmatterPlugin: MarkdownIt.PluginWithOptions<FrontmatterPluginOptions>;
|
|
48
|
+
|
|
49
|
+
export { type FrontmatterPluginOptions, frontmatterPlugin };
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-frontmatter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A markdown-it plugin to get markdown frontmatter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -22,9 +22,14 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
|
+
"default": "./dist/index.cjs"
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
"main": "./dist/index.cjs",
|
|
@@ -38,13 +43,13 @@
|
|
|
38
43
|
"test": "vitest"
|
|
39
44
|
},
|
|
40
45
|
"dependencies": {
|
|
41
|
-
"@mdit-vue/types": "0.
|
|
42
|
-
"@types/markdown-it": "^
|
|
46
|
+
"@mdit-vue/types": "1.0.0",
|
|
47
|
+
"@types/markdown-it": "^13.0.1",
|
|
43
48
|
"gray-matter": "^4.0.3",
|
|
44
49
|
"markdown-it": "^13.0.1"
|
|
45
50
|
},
|
|
46
51
|
"publishConfig": {
|
|
47
52
|
"access": "public"
|
|
48
53
|
},
|
|
49
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d5388b9a8ec1e9075c41587410151ec2a6bc0df1"
|
|
50
55
|
}
|