@mdit-vue/plugin-title 3.0.2 → 4.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/README.md CHANGED
@@ -17,11 +17,11 @@ npm i @mdit-vue/plugin-title
17
17
 
18
18
  ```ts
19
19
  import { titlePlugin } from '@mdit-vue/plugin-title';
20
- import type { MarkdownItEnv } from '@mdit-vue/types';
20
+ import type { Env } from 'markdown-it';
21
21
  import MarkdownIt from 'markdown-it';
22
22
 
23
23
  const md = MarkdownIt({ html: true }).use(titlePlugin);
24
- const env: MarkdownItEnv = {};
24
+ const env: Env = {};
25
25
 
26
26
  const rendered = md.render(
27
27
  `\
package/dist/index.d.ts CHANGED
@@ -1,22 +1,15 @@
1
- import { PluginSimple } from "markdown-it";
2
-
3
- //#region src/title-plugin.d.ts
4
-
1
+ import { MarkdownItPlugin } from "@mdit-vue/types";
5
2
  /**
6
3
  * Get markdown page title info
7
4
  *
8
5
  * Extract it into env
9
6
  */
10
- declare const titlePlugin: PluginSimple;
11
- //#endregion
12
- //#region src/types.d.ts
13
- declare module '@mdit-vue/types' {
14
- interface MarkdownItEnv {
7
+ export declare const titlePlugin: MarkdownItPlugin;
8
+ declare module 'markdown-it' {
9
+ interface Env {
15
10
  /**
16
11
  * The title that extracted by `@mdit-vue/plugin-title`
17
12
  */
18
13
  title?: string;
19
14
  }
20
- }
21
- //#endregion
22
- export { titlePlugin };
15
+ }
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { resolveTitleFromToken } from "@mdit-vue/shared";
2
-
3
- //#region src/title-plugin.ts
2
+ // src/title-plugin.ts
4
3
  /**
5
4
  * Get markdown page title info
6
5
  *
@@ -8,7 +7,7 @@ import { resolveTitleFromToken } from "@mdit-vue/shared";
8
7
  */
9
8
  const titlePlugin = (md) => {
10
9
  const render = md.renderer.render.bind(md.renderer);
11
- md.renderer.render = (tokens, options, env) => {
10
+ md.renderer.render = (tokens, options, env = {}) => {
12
11
  const tokenIdx = tokens.findIndex((token) => token.tag === "h1");
13
12
  env.title = tokenIdx > -1 ? resolveTitleFromToken(tokens[tokenIdx + 1], {
14
13
  shouldAllowHtml: false,
@@ -17,6 +16,4 @@ const titlePlugin = (md) => {
17
16
  return render(tokens, options, env);
18
17
  };
19
18
  };
20
-
21
- //#endregion
22
- export { titlePlugin };
19
+ export { titlePlugin };
package/package.json CHANGED
@@ -1,56 +1,52 @@
1
1
  {
2
2
  "name": "@mdit-vue/plugin-title",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "description": "A markdown-it plugin to get markdown page title",
5
5
  "keywords": [
6
6
  "markdown-it",
7
7
  "markdown-it-plugin",
8
- "vue",
9
- "title"
8
+ "title",
9
+ "vue"
10
10
  ],
11
11
  "homepage": "https://github.com/mdit-vue",
12
12
  "bugs": {
13
13
  "url": "https://github.com/mdit-vue/mdit-vue/issues"
14
14
  },
15
+ "license": "MIT",
16
+ "author": "meteorlxy <meteor.lxy@foxmail.com>",
15
17
  "repository": {
16
18
  "type": "git",
17
19
  "url": "git+https://github.com/mdit-vue/mdit-vue.git"
18
20
  },
19
- "license": "MIT",
20
- "author": "meteorlxy <meteor.lxy@foxmail.com>",
21
+ "files": [
22
+ "./dist"
23
+ ],
21
24
  "type": "module",
25
+ "types": "./dist/index.d.ts",
22
26
  "exports": {
23
27
  ".": "./dist/index.js",
24
28
  "./package.json": "./package.json"
25
29
  },
26
- "main": "./dist/index.js",
27
- "module": "./dist/index.js",
28
- "types": "./dist/index.d.ts",
29
- "files": [
30
- "./dist"
31
- ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
32
33
  "scripts": {
33
34
  "build": "tsdown",
34
35
  "clean": "rimraf ./dist",
35
36
  "test": "vitest"
36
37
  },
37
38
  "dependencies": {
38
- "@mdit-vue/shared": "3.0.2",
39
- "@mdit-vue/types": "3.0.2",
40
- "@types/markdown-it": "^14.1.2",
41
- "markdown-it": "^14.1.0"
39
+ "@mdit-vue/shared": "4.0.0",
40
+ "@mdit-vue/types": "4.0.0",
41
+ "markdown-it": "^15.0.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/markdown-it-emoji": "^3.0.1",
45
- "markdown-it-emoji": "^3.0.0",
46
- "tsdown": "^0.14.1",
47
- "vitest": "^3.2.4"
44
+ "markdown-it-emoji": "^3.1.0",
45
+ "tsdown": "^0.23.7",
46
+ "vitest": "^5.1.0"
48
47
  },
49
48
  "engines": {
50
- "node": ">=20.0.0"
51
- },
52
- "publishConfig": {
53
- "access": "public"
49
+ "node": ">=20.19.0"
54
50
  },
55
- "gitHead": "3b5332d09fbd927319bd8be3ba3b86b3d12d1ec8"
51
+ "gitHead": "62f17856a1a5dec0e33c6487453a927b82a5883b"
56
52
  }