Skip to content

Commit 691da8f

Browse files
committed
add toc options
1 parent 7194f47 commit 691da8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const remarkTableOfContents: Plugin = function plugin(
1616

1717
const mdast = ast as Root
1818

19-
const result = toc(mdast)
19+
// remove the one property that is not a toc option
20+
const { mdx, ...tocOptions } = options
21+
22+
const result = toc(mdast, tocOptions)
23+
2024
const list = result.map
2125

2226
if (list === null) {
@@ -31,7 +35,7 @@ const remarkTableOfContents: Plugin = function plugin(
3135
return
3236
}
3337

34-
if (options.mdx) {
38+
if (mdx) {
3539
mdast.children = Array.prototype.concat(
3640
mdast.children.slice(0, index),
3741
{
@@ -40,7 +44,6 @@ const remarkTableOfContents: Plugin = function plugin(
4044
children: [result.map],
4145
attributes: []
4246
},
43-
4447
mdast.children.slice(index + 1)
4548
)
4649
} else {

0 commit comments

Comments
 (0)