File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ const checkTableOfContents = ( ) => {
2+ const toc = document . getElementById ( "main" ) . querySelector ( ".table-of-contents" )
3+ const skipToMain = document . querySelector ( 'a[href="#main"]' )
4+ const navSkip = document . querySelector ( ".nav-skip" )
5+ if ( ! toc ) return
6+
7+ let nextCandidate = toc ?. nextElementSibling
8+ nextCandidate . id = "pass-toc"
9+
10+ const skipLink = createSkipLink ( nextCandidate . id )
11+ navSkip . insertBefore ( skipLink , skipToMain . nextSibling )
12+ }
13+
14+ const createSkipLink = ( id , text = "Skip pass the Table of Contents" ) => {
15+ const skipLink = document . createElement ( 'a' )
16+ skipLink . className = 'nav-skipto'
17+ skipLink . href = `#${ id } `
18+ skipLink . innerText = text
19+ return skipLink
20+ }
21+
22+ checkTableOfContents ( )
123Array . from ( document . links ) . filter ( link => link . hostname != window . location . hostname )
2- . forEach ( link => link . target = '_blank' )
24+ . forEach ( link => link . target = '_blank' )
You can’t perform that action at this time.
0 commit comments