File tree 3 files changed +17
-12
lines changed
3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,7 @@ <h1>Node.js __VERSION__ Documentation</h1>
55
55
< hr >
56
56
</ header >
57
57
58
- < details id ="toc " open >
59
- < summary > Table of Contents</ summary >
60
- __TOC__
61
- </ details >
58
+ __TOC__
62
59
63
60
< div id ="apicontent ">
64
61
__CONTENT__
Original file line number Diff line number Diff line change @@ -59,9 +59,11 @@ let all = toc.replace(/index\.html/g, 'all.html')
59
59
all = all . replace ( / < t i t l e > .* ?\| / , '<title>' ) ;
60
60
61
61
// Insert the combined table of contents.
62
- const tocStart = / < \w + i d = " t o c " [ ^ > ] * > \s * < \w + > . * ? < \/ \w + > \s * / . exec ( all ) ;
62
+ const tocStart = / < ! - - T O C - - > / . exec ( all ) ;
63
63
all = all . slice ( 0 , tocStart . index + tocStart [ 0 ] . length ) +
64
+ '<details id="toc" open><summary>Table of contents</summary>\n' +
64
65
'<ul>\n' + contents + '</ul>\n' +
66
+ '</details>\n' +
65
67
all . slice ( tocStart . index + tocStart [ 0 ] . length ) ;
66
68
67
69
// Replace apicontent with the concatenated set of apicontents from each source.
Original file line number Diff line number Diff line change @@ -382,13 +382,19 @@ function buildToc({ filename, apilinks }) {
382
382
node . children . push ( { type : 'html' , value : anchor } ) ;
383
383
} ) ;
384
384
385
- file . toc = unified ( )
386
- . use ( markdown )
387
- . use ( gfm )
388
- . use ( remark2rehype , { allowDangerousHtml : true } )
389
- . use ( raw )
390
- . use ( htmlStringify )
391
- . processSync ( toc ) . toString ( ) ;
385
+ if ( toc !== '' ) {
386
+ file . toc = '<details id="toc" open><summary>Table of contents</summary>' +
387
+ unified ( )
388
+ . use ( markdown )
389
+ . use ( gfm )
390
+ . use ( remark2rehype , { allowDangerousHtml : true } )
391
+ . use ( raw )
392
+ . use ( htmlStringify )
393
+ . processSync ( toc ) . toString ( ) +
394
+ '</details>' ;
395
+ } else {
396
+ file . toc = '<!-- TOC -->' ;
397
+ }
392
398
} ;
393
399
}
394
400
You can’t perform that action at this time.
0 commit comments