@mdit-vue/plugin-frontmatter 3.0.0 → 3.0.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.
package/dist/index.d.ts CHANGED
@@ -1,50 +1,51 @@
1
- import { PluginWithOptions } from 'markdown-it';
2
- import matter from 'gray-matter';
1
+ import grayMatter from "gray-matter";
2
+ import { PluginWithOptions } from "markdown-it";
3
3
 
4
- type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
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
- * Options of gray-matter
11
- *
12
- * @see https://github.com/jonschlinkert/gray-matter#options
26
+ * The raw Markdown content without frontmatter
13
27
  */
14
- grayMatterOptions?: GrayMatterOptions;
28
+ content?: string;
15
29
  /**
16
- * Render the excerpt or not
30
+ * The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
17
31
  *
18
- * @default true
32
+ * - Would be the rendered HTML when `renderExcerpt` is enabled
33
+ * - Would be the raw Markdown when `renderExcerpt` is disabled
19
34
  */
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
- }
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.0",
3
+ "version": "3.0.1",
4
4
  "description": "A markdown-it plugin to get markdown frontmatter",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -21,15 +21,12 @@
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.cjs",
31
- "module": "./dist/index.mjs",
32
- "types": "./dist/index.d.cts",
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
33
30
  "files": [
34
31
  "./dist"
35
32
  ],
@@ -38,7 +35,7 @@
38
35
  "test": "vitest"
39
36
  },
40
37
  "dependencies": {
41
- "@mdit-vue/types": "3.0.0",
38
+ "@mdit-vue/types": "3.0.1",
42
39
  "@types/markdown-it": "^14.1.2",
43
40
  "gray-matter": "^4.0.3",
44
41
  "markdown-it": "^14.1.0"
@@ -53,5 +50,5 @@
53
50
  "publishConfig": {
54
51
  "access": "public"
55
52
  },
56
- "gitHead": "bbb62a47109c2932505b3f570b963f70d590914f"
53
+ "gitHead": "cdffe386ef7b897f1bf878ce20e38bdd07908fb1"
57
54
  }
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