@mehm8128/rehype-toc 1.4.2 → 1.4.3
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.js +9 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const rehypeCollapsibleToc = () => {
|
|
|
6
6
|
const rootOlElement = {
|
|
7
7
|
type: "element",
|
|
8
8
|
tagName: "ol",
|
|
9
|
-
properties: {},
|
|
9
|
+
properties: { className: ["rehype-toc-ol"] },
|
|
10
10
|
children: []
|
|
11
11
|
};
|
|
12
12
|
visit(tree, "element", (node) => {
|
|
@@ -63,7 +63,7 @@ const createOlElement = () => {
|
|
|
63
63
|
return {
|
|
64
64
|
type: "element",
|
|
65
65
|
tagName: "ol",
|
|
66
|
-
properties: {},
|
|
66
|
+
properties: { className: ["rehype-toc-ol"] },
|
|
67
67
|
children: []
|
|
68
68
|
};
|
|
69
69
|
};
|
|
@@ -76,7 +76,10 @@ const createListItemElement = (node) => {
|
|
|
76
76
|
const anchorElement = {
|
|
77
77
|
type: "element",
|
|
78
78
|
tagName: "a",
|
|
79
|
-
properties: {
|
|
79
|
+
properties: {
|
|
80
|
+
href: `#${headingId}`,
|
|
81
|
+
className: ["rehype-toc-a"]
|
|
82
|
+
},
|
|
80
83
|
children: [{
|
|
81
84
|
type: "text",
|
|
82
85
|
value: headingText
|
|
@@ -85,7 +88,7 @@ const createListItemElement = (node) => {
|
|
|
85
88
|
return {
|
|
86
89
|
type: "element",
|
|
87
90
|
tagName: "li",
|
|
88
|
-
properties: {},
|
|
91
|
+
properties: { className: ["rehype-toc-li"] },
|
|
89
92
|
children: [anchorElement]
|
|
90
93
|
};
|
|
91
94
|
};
|
|
@@ -93,7 +96,7 @@ const createCollapsibleToc = (rootOlElement) => {
|
|
|
93
96
|
const summaryElement = {
|
|
94
97
|
type: "element",
|
|
95
98
|
tagName: "summary",
|
|
96
|
-
properties: {},
|
|
99
|
+
properties: { className: ["rehype-toc-summary"] },
|
|
97
100
|
children: [{
|
|
98
101
|
type: "text",
|
|
99
102
|
value: "目次"
|
|
@@ -102,7 +105,7 @@ const createCollapsibleToc = (rootOlElement) => {
|
|
|
102
105
|
const detailsElement = {
|
|
103
106
|
type: "element",
|
|
104
107
|
tagName: "details",
|
|
105
|
-
properties: {},
|
|
108
|
+
properties: { className: ["rehype-toc-details"] },
|
|
106
109
|
children: [summaryElement, rootOlElement]
|
|
107
110
|
};
|
|
108
111
|
return detailsElement;
|