@mdit-vue/plugin-title 3.0.1 → 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 +2 -2
- package/dist/index.d.ts +10 -7
- package/dist/index.js +3 -6
- package/package.json +21 -24
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 {
|
|
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:
|
|
24
|
+
const env: Env = {};
|
|
25
25
|
|
|
26
26
|
const rendered = md.render(
|
|
27
27
|
`\
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export declare const titlePlugin: MarkdownItPlugin;
|
|
8
|
+
declare module 'markdown-it' {
|
|
9
|
+
interface Env {
|
|
10
|
+
/**
|
|
11
|
+
* The title that extracted by `@mdit-vue/plugin-title`
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
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,55 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-title",
|
|
3
|
-
"version": "
|
|
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
|
-
"
|
|
9
|
-
"
|
|
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
|
-
"
|
|
20
|
-
|
|
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
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"files": [
|
|
30
|
-
"./dist"
|
|
31
|
-
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "tsdown",
|
|
35
|
+
"clean": "rimraf ./dist",
|
|
34
36
|
"test": "vitest"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
|
-
"@mdit-vue/shared": "
|
|
38
|
-
"@mdit-vue/types": "
|
|
39
|
-
"
|
|
40
|
-
"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"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"vitest": "^3.2.4"
|
|
44
|
+
"markdown-it-emoji": "^3.1.0",
|
|
45
|
+
"tsdown": "^0.23.7",
|
|
46
|
+
"vitest": "^5.1.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=20.
|
|
50
|
-
},
|
|
51
|
-
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
49
|
+
"node": ">=20.19.0"
|
|
53
50
|
},
|
|
54
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "62f17856a1a5dec0e33c6487453a927b82a5883b"
|
|
55
52
|
}
|