File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 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>
5555 < hr >
5656 </ header >
5757
58- < details id ="toc " open >
59- < summary > Table of Contents</ summary >
60- __TOC__
61- </ details >
58+ __TOC__
6259
6360 < div id ="apicontent ">
6461 __CONTENT__
Original file line number Diff line number Diff line change @@ -59,9 +59,11 @@ let all = toc.replace(/index\.html/g, 'all.html')
5959all = all . replace ( / < t i t l e > .* ?\| / , '<title>' ) ;
6060
6161// 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 ) ;
6363all = all . slice ( 0 , tocStart . index + tocStart [ 0 ] . length ) +
64+ '<details id="toc" open><summary>Table of contents</summary>\n' +
6465 '<ul>\n' + contents + '</ul>\n' +
66+ '</details>\n' +
6567 all . slice ( tocStart . index + tocStart [ 0 ] . length ) ;
6668
6769// 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 }) {
382382 node . children . push ( { type : 'html' , value : anchor } ) ;
383383 } ) ;
384384
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+ }
392398 } ;
393399}
394400
You can’t perform that action at this time.
0 commit comments