File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 108
108
shouldStable : false ,
109
109
version : versionNumber ,
110
110
oldVersion : undefined ,
111
- versionOptions : [ 'master' ]
111
+ versionOptions : [ 'master' ] ,
112
+ scrolledOnce : false ,
112
113
} ,
113
114
asyncComputed : {
114
115
async outputHtml ( ) {
156
157
renderer . heading = function ( text , level ) {
157
158
const id = htmlToId ( text ) ;
158
159
return `<h${ level } >
159
- <a href="#${ id } " name="${ id } " class="header-link">${ text } </a>
160
+ <a id=" ${ id } " href="#${ id } " name="${ id } " class="header-link">${ text } </a>
160
161
</h${ level } >` ;
161
162
} ;
162
163
163
- return marked . parser ( ast , {
164
+ const html = marked . parser ( ast , {
164
165
highlight ( code , lang ) {
165
166
return hljs . highlight ( lang ? lang : 'rust' , code ) . value ;
166
167
} ,
167
168
headerIds : true ,
168
169
headerPrefix : '' ,
169
170
renderer,
170
171
} ) ;
172
+ document . dispatchEvent ( new Event ( 'htmlbuilt' ) ) ;
173
+ return html ;
171
174
}
172
175
} ,
173
176
created : async function ( ) {
178
181
. filter ( tag => tag . startsWith ( 'v' ) ) ;
179
182
this . versionOptions = this . versionOptions . concat ( tagOptions ) ;
180
183
} ,
181
- mounted ( ) {
184
+ updated : function ( ) {
182
185
if ( UrlHash === '' ) return ;
183
- const target = document . querySelector ( `#${ UrlHash } ` ) ;
184
- if ( target != null ) {
185
- target . scrollIntoView ( true ) ;
186
- }
186
+ this . $nextTick ( ( ) => {
187
+ const target = document . querySelector ( `#${ UrlHash } ` ) ;
188
+ if ( target != null && ! this . scrolledOnce ) {
189
+ target . scrollIntoView ( true ) ;
190
+ this . scrolledOnce = true ;
191
+ }
192
+ } ) ;
187
193
}
188
194
} ) ;
189
195
const extractDepthOnes = ( ast ) => {
You can’t perform that action at this time.
0 commit comments