@@ -123,21 +123,25 @@ $(document).ready(function () {
123
123
} ) ;
124
124
125
125
// Add anchors for headings
126
- document
127
- . querySelector ( ".page__content" )
128
- . querySelectorAll ( "h1, h2, h3, h4, h5, h6" )
129
- . forEach ( function ( element ) {
130
- var id = element . getAttribute ( "id" ) ;
131
- if ( id ) {
132
- var anchor = document . createElement ( "a" ) ;
133
- anchor . className = "header-link" ;
134
- anchor . href = "#" + id ;
135
- anchor . innerHTML =
136
- '<span class="sr-only">Permalink</span><i class="fas fa-link"></i>' ;
137
- anchor . title = "Permalink" ;
138
- element . appendChild ( anchor ) ;
139
- }
140
- } ) ;
126
+ ( function ( ) {
127
+ var pageContentElement = document . querySelector ( ".page__content" ) ;
128
+ if ( ! pageContentElement ) return ;
129
+
130
+ pageContentElement
131
+ . querySelectorAll ( "h1, h2, h3, h4, h5, h6" )
132
+ . forEach ( function ( element ) {
133
+ var id = element . getAttribute ( "id" ) ;
134
+ if ( id ) {
135
+ var anchor = document . createElement ( "a" ) ;
136
+ anchor . className = "header-link" ;
137
+ anchor . href = "#" + id ;
138
+ anchor . innerHTML =
139
+ '<span class="sr-only">Permalink</span><i class="fas fa-link"></i>' ;
140
+ anchor . title = "Permalink" ;
141
+ element . appendChild ( anchor ) ;
142
+ }
143
+ } ) ;
144
+ } ) ( ) ;
141
145
142
146
// Add copy button for <pre> blocks
143
147
var copyText = function ( text ) {
0 commit comments