@mdit-vue/plugin-toc 0.9.2 → 0.11.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.cjs +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -17,9 +17,9 @@ const createRenderHeaders = ({
|
|
|
17
17
|
const itemClassString = itemClass ? ` class="${shared.htmlEscape(itemClass)}"` : "";
|
|
18
18
|
const linkTagString = shared.htmlEscape(linkTag);
|
|
19
19
|
const linkClassString = linkClass ? ` class="${shared.htmlEscape(linkClass)}"` : "";
|
|
20
|
-
const linkTo = (
|
|
20
|
+
const linkTo = (link) => linkTag === "router-link" ? ` to="${link}"` : ` href="${link}"`;
|
|
21
21
|
const renderHeaders = (headers) => `<${listTagString}${listClassString}>${headers.map(
|
|
22
|
-
(header) => `<${itemTagString}${itemClassString}${itemClassString}><${linkTagString}${linkClassString}${linkTo(header.
|
|
22
|
+
(header) => `<${itemTagString}${itemClassString}${itemClassString}><${linkTagString}${linkClassString}${linkTo(header.link)}>${header.title}</${linkTagString}>${header.children.length > 0 ? renderHeaders(header.children) : ""}</${itemTagString}>`
|
|
23
23
|
).join("")}</${listTagString}>`;
|
|
24
24
|
return renderHeaders;
|
|
25
25
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarkdownItHeader } from '@mdit-vue/types';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import ParserBlock from 'markdown-it/lib/parser_block.js';
|
|
3
|
+
import MarkdownIt from 'markdown-it';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Options of @mdit-vue/plugin-toc
|
|
@@ -87,7 +87,7 @@ declare const createRenderHeaders: ({ listTag, listClass, itemClass, linkTag, li
|
|
|
87
87
|
*
|
|
88
88
|
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
89
89
|
*/
|
|
90
|
-
declare const createTocBlockRule: ({ pattern, containerTag, containerClass, }: Pick<Required<TocPluginOptions>, 'pattern' | 'containerTag' | 'containerClass'>) => RuleBlock;
|
|
90
|
+
declare const createTocBlockRule: ({ pattern, containerTag, containerClass, }: Pick<Required<TocPluginOptions>, 'pattern' | 'containerTag' | 'containerClass'>) => ParserBlock.RuleBlock;
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Generate table of contents
|
|
@@ -96,6 +96,6 @@ declare const createTocBlockRule: ({ pattern, containerTag, containerClass, }: P
|
|
|
96
96
|
*
|
|
97
97
|
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
98
98
|
*/
|
|
99
|
-
declare const tocPlugin: PluginWithOptions<TocPluginOptions>;
|
|
99
|
+
declare const tocPlugin: MarkdownIt.PluginWithOptions<TocPluginOptions>;
|
|
100
100
|
|
|
101
101
|
export { TocPluginOptions, createRenderHeaders, createTocBlockRule, tocPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -13,9 +13,9 @@ const createRenderHeaders = ({
|
|
|
13
13
|
const itemClassString = itemClass ? ` class="${htmlEscape(itemClass)}"` : "";
|
|
14
14
|
const linkTagString = htmlEscape(linkTag);
|
|
15
15
|
const linkClassString = linkClass ? ` class="${htmlEscape(linkClass)}"` : "";
|
|
16
|
-
const linkTo = (
|
|
16
|
+
const linkTo = (link) => linkTag === "router-link" ? ` to="${link}"` : ` href="${link}"`;
|
|
17
17
|
const renderHeaders = (headers) => `<${listTagString}${listClassString}>${headers.map(
|
|
18
|
-
(header) => `<${itemTagString}${itemClassString}${itemClassString}><${linkTagString}${linkClassString}${linkTo(header.
|
|
18
|
+
(header) => `<${itemTagString}${itemClassString}${itemClassString}><${linkTagString}${linkClassString}${linkTo(header.link)}>${header.title}</${linkTagString}>${header.children.length > 0 ? renderHeaders(header.children) : ""}</${itemTagString}>`
|
|
19
19
|
).join("")}</${listTagString}>`;
|
|
20
20
|
return renderHeaders;
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-toc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "A markdown-it plugin to generate table-of-contents that compatible with Vue.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"test": "vitest"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mdit-vue/shared": "0.
|
|
42
|
-
"@mdit-vue/types": "0.
|
|
41
|
+
"@mdit-vue/shared": "0.11.0",
|
|
42
|
+
"@mdit-vue/types": "0.11.0",
|
|
43
43
|
"@types/markdown-it": "^12.2.3",
|
|
44
44
|
"markdown-it": "^13.0.1"
|
|
45
45
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "98828479d07c7bc52d178a00cdb92c166eff09ee"
|
|
53
53
|
}
|