File tree 2 files changed +18
-1
lines changed
island/src/node/plugin-mdx/remarkPlugins
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,12 @@ interface TocItem {
12
12
depth : number ;
13
13
}
14
14
15
+ interface ChildNode {
16
+ type : 'link' | 'text' | 'inlineCode' ;
17
+ value : string ;
18
+ children ?: ChildNode [ ] ;
19
+ }
20
+
15
21
export const remarkPluginToc : Plugin = ( ) => {
16
22
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17
23
return ( tree : any ) => {
@@ -27,7 +33,13 @@ export const remarkPluginToc: Plugin = () => {
27
33
28
34
if ( node . type === 'heading' && node . depth > 1 && node . depth < 5 ) {
29
35
const originText = node . children
30
- . map ( ( child : { value : string } ) => child . value )
36
+ . map ( ( child : ChildNode ) => {
37
+ if ( child . type === 'link' ) {
38
+ return child . children ?. map ( ( item ) => item . value ) . join ( '' ) ;
39
+ } else {
40
+ return child . value ;
41
+ }
42
+ } )
31
43
. join ( '' ) ;
32
44
const id = slugger . slug ( originText ) ;
33
45
const depth = node . depth ;
Original file line number Diff line number Diff line change @@ -5,4 +5,9 @@ declare module '*.svg' {
5
5
React . SVGProps < SVGSVGElement > & AttributifyAttributes
6
6
> ;
7
7
export = ReactComponent ;
8
+ }
9
+
10
+ declare module '*.module.scss' {
11
+ const classes : { [ key : string ] : string } ;
12
+ export default classes ;
8
13
}
You can’t perform that action at this time.
0 commit comments