File tree 3 files changed +40
-34
lines changed 3 files changed +40
-34
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {import('mdast').Root } Root
3
- * @typedef {import('mdast-util-toc').Options } Options
2
+ * @typedef {import('./lib/index.js').Options } Options
4
3
*/
5
4
6
- import { toc } from 'mdast-util-toc'
7
-
8
- /**
9
- * Plugin to generate a Table of Contents (TOC).
10
- *
11
- * @type {import('unified').Plugin<[Options?]|void[], Root> }
12
- */
13
- export default function remarkToc ( options = { } ) {
14
- return ( node ) => {
15
- const result = toc (
16
- node ,
17
- Object . assign ( { } , options , {
18
- heading : options . heading || 'toc|table[ -]of[ -]contents?'
19
- } )
20
- )
21
-
22
- if (
23
- result . endIndex === null ||
24
- result . index === null ||
25
- result . index === - 1 ||
26
- ! result . map
27
- ) {
28
- return
29
- }
30
-
31
- node . children = [
32
- ...node . children . slice ( 0 , result . index ) ,
33
- result . map ,
34
- ...node . children . slice ( result . endIndex )
35
- ]
36
- }
37
- }
5
+ export { default } from './lib/index.js'
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @typedef {import('mdast').Root } Root
3
+ * @typedef {import('mdast-util-toc').Options } Options
4
+ */
5
+
6
+ import { toc } from 'mdast-util-toc'
7
+
8
+ /**
9
+ * Plugin to generate a Table of Contents (TOC).
10
+ *
11
+ * @type {import('unified').Plugin<[Options?]|void[], Root> }
12
+ */
13
+ export default function remarkToc ( options = { } ) {
14
+ return ( node ) => {
15
+ const result = toc (
16
+ node ,
17
+ Object . assign ( { } , options , {
18
+ heading : options . heading || 'toc|table[ -]of[ -]contents?'
19
+ } )
20
+ )
21
+
22
+ if (
23
+ result . endIndex === null ||
24
+ result . index === null ||
25
+ result . index === - 1 ||
26
+ ! result . map
27
+ ) {
28
+ return
29
+ }
30
+
31
+ node . children = [
32
+ ...node . children . slice ( 0 , result . index ) ,
33
+ result . map ,
34
+ ...node . children . slice ( result . endIndex )
35
+ ]
36
+ }
37
+ }
Original file line number Diff line number Diff line change 34
34
"main" : " index.js" ,
35
35
"types" : " index.d.ts" ,
36
36
"files" : [
37
+ " lib/" ,
37
38
" index.d.ts" ,
38
39
" index.js"
39
40
],
You can’t perform that action at this time.
0 commit comments