@mdit-vue/plugin-frontmatter 3.0.0 → 3.0.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/dist/index.d.ts +34 -33
- package/package.json +9 -11
- package/dist/index.cjs +0 -47
- package/dist/index.d.cts +0 -51
- package/dist/index.d.mts +0 -51
- /package/dist/{index.mjs → index.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import grayMatter from "gray-matter";
|
|
2
|
+
import { PluginWithOptions } from "markdown-it";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
type GrayMatterOptions = grayMatter.GrayMatterOption<string, GrayMatterOptions>;
|
|
5
6
|
/**
|
|
6
7
|
* Options of @mdit-vue/plugin-frontmatter
|
|
7
8
|
*/
|
|
8
9
|
interface FrontmatterPluginOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Options of gray-matter
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
14
|
+
*/
|
|
15
|
+
grayMatterOptions?: GrayMatterOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Render the excerpt or not
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
renderExcerpt?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare module '@mdit-vue/types' {
|
|
24
|
+
interface MarkdownItEnv {
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
26
|
+
* The raw Markdown content without frontmatter
|
|
13
27
|
*/
|
|
14
|
-
|
|
28
|
+
content?: string;
|
|
15
29
|
/**
|
|
16
|
-
*
|
|
30
|
+
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
|
17
31
|
*
|
|
18
|
-
*
|
|
32
|
+
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
|
33
|
+
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
|
19
34
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
35
|
+
excerpt?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
|
38
|
+
*/
|
|
39
|
+
frontmatter?: Record<string, unknown>;
|
|
40
|
+
}
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/frontmatter-plugin.d.ts
|
|
42
44
|
/**
|
|
43
45
|
* Get markdown frontmatter and excerpt
|
|
44
46
|
*
|
|
45
47
|
* Extract them into env
|
|
46
48
|
*/
|
|
47
49
|
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
|
|
48
|
-
|
|
49
|
-
export { frontmatterPlugin };
|
|
50
|
-
export type { FrontmatterPluginOptions };
|
|
50
|
+
//#endregion
|
|
51
|
+
export { FrontmatterPluginOptions, frontmatterPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-frontmatter",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A markdown-it plugin to get markdown frontmatter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -21,30 +21,28 @@
|
|
|
21
21
|
"author": "meteorlxy <meteor.lxy@foxmail.com>",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
"import": "./dist/index.mjs",
|
|
26
|
-
"require": "./dist/index.cjs"
|
|
27
|
-
},
|
|
24
|
+
".": "./dist/index.js",
|
|
28
25
|
"./package.json": "./package.json"
|
|
29
26
|
},
|
|
30
|
-
"main": "./dist/index.
|
|
31
|
-
"module": "./dist/index.
|
|
32
|
-
"types": "./dist/index.d.
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
33
30
|
"files": [
|
|
34
31
|
"./dist"
|
|
35
32
|
],
|
|
36
33
|
"scripts": {
|
|
37
34
|
"build": "tsdown",
|
|
35
|
+
"clean": "rimraf ./dist",
|
|
38
36
|
"test": "vitest"
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"@mdit-vue/types": "3.0.
|
|
39
|
+
"@mdit-vue/types": "3.0.2",
|
|
42
40
|
"@types/markdown-it": "^14.1.2",
|
|
43
41
|
"gray-matter": "^4.0.3",
|
|
44
42
|
"markdown-it": "^14.1.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"tsdown": "^0.14.
|
|
45
|
+
"tsdown": "^0.14.1",
|
|
48
46
|
"vitest": "^3.2.4"
|
|
49
47
|
},
|
|
50
48
|
"engines": {
|
|
@@ -53,5 +51,5 @@
|
|
|
53
51
|
"publishConfig": {
|
|
54
52
|
"access": "public"
|
|
55
53
|
},
|
|
56
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "3b5332d09fbd927319bd8be3ba3b86b3d12d1ec8"
|
|
57
55
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const gray_matter = __toESM(require("gray-matter"));
|
|
25
|
-
|
|
26
|
-
//#region src/frontmatter-plugin.ts
|
|
27
|
-
/**
|
|
28
|
-
* Get markdown frontmatter and excerpt
|
|
29
|
-
*
|
|
30
|
-
* Extract them into env
|
|
31
|
-
*/
|
|
32
|
-
const frontmatterPlugin = (md, { grayMatterOptions, renderExcerpt = true } = {}) => {
|
|
33
|
-
const parse = md.parse.bind(md);
|
|
34
|
-
md.parse = (src, env = {}) => {
|
|
35
|
-
const { data, content, excerpt = "" } = (0, gray_matter.default)(src, grayMatterOptions);
|
|
36
|
-
env.content = content;
|
|
37
|
-
env.frontmatter = {
|
|
38
|
-
...env.frontmatter,
|
|
39
|
-
...data
|
|
40
|
-
};
|
|
41
|
-
env.excerpt = renderExcerpt && excerpt ? md.render(excerpt, { ...env }) : excerpt;
|
|
42
|
-
return parse(content, env);
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
exports.frontmatterPlugin = frontmatterPlugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { PluginWithOptions } from "markdown-it";
|
|
2
|
-
import matter from "gray-matter";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-frontmatter
|
|
8
|
-
*/
|
|
9
|
-
interface FrontmatterPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Options of gray-matter
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
14
|
-
*/
|
|
15
|
-
grayMatterOptions?: GrayMatterOptions;
|
|
16
|
-
/**
|
|
17
|
-
* Render the excerpt or not
|
|
18
|
-
*
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
renderExcerpt?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare module '@mdit-vue/types' {
|
|
24
|
-
interface MarkdownItEnv {
|
|
25
|
-
/**
|
|
26
|
-
* The raw Markdown content without frontmatter
|
|
27
|
-
*/
|
|
28
|
-
content?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
|
31
|
-
*
|
|
32
|
-
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
|
33
|
-
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
|
34
|
-
*/
|
|
35
|
-
excerpt?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
|
38
|
-
*/
|
|
39
|
-
frontmatter?: Record<string, unknown>;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/frontmatter-plugin.d.ts
|
|
44
|
-
/**
|
|
45
|
-
* Get markdown frontmatter and excerpt
|
|
46
|
-
*
|
|
47
|
-
* Extract them into env
|
|
48
|
-
*/
|
|
49
|
-
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { FrontmatterPluginOptions, frontmatterPlugin };
|
package/dist/index.d.mts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import grayMatter from "gray-matter";
|
|
2
|
-
import { PluginWithOptions } from "markdown-it";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type GrayMatterOptions = grayMatter.GrayMatterOption<string, GrayMatterOptions>;
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-frontmatter
|
|
8
|
-
*/
|
|
9
|
-
interface FrontmatterPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Options of gray-matter
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/jonschlinkert/gray-matter#options
|
|
14
|
-
*/
|
|
15
|
-
grayMatterOptions?: GrayMatterOptions;
|
|
16
|
-
/**
|
|
17
|
-
* Render the excerpt or not
|
|
18
|
-
*
|
|
19
|
-
* @default true
|
|
20
|
-
*/
|
|
21
|
-
renderExcerpt?: boolean;
|
|
22
|
-
}
|
|
23
|
-
declare module '@mdit-vue/types' {
|
|
24
|
-
interface MarkdownItEnv {
|
|
25
|
-
/**
|
|
26
|
-
* The raw Markdown content without frontmatter
|
|
27
|
-
*/
|
|
28
|
-
content?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
|
31
|
-
*
|
|
32
|
-
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
|
33
|
-
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
|
34
|
-
*/
|
|
35
|
-
excerpt?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
|
38
|
-
*/
|
|
39
|
-
frontmatter?: Record<string, unknown>;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/frontmatter-plugin.d.ts
|
|
44
|
-
/**
|
|
45
|
-
* Get markdown frontmatter and excerpt
|
|
46
|
-
*
|
|
47
|
-
* Extract them into env
|
|
48
|
-
*/
|
|
49
|
-
declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { FrontmatterPluginOptions, frontmatterPlugin };
|
|
File without changes
|