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 108108 shouldStable : false ,
109109 version : versionNumber ,
110110 oldVersion : undefined ,
111- versionOptions : [ 'master' ]
111+ versionOptions : [ 'master' ] ,
112+ scrolledOnce : false ,
112113 } ,
113114 asyncComputed : {
114115 async outputHtml ( ) {
156157 renderer . heading = function ( text , level ) {
157158 const id = htmlToId ( text ) ;
158159 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>
160161 </h${ level } >` ;
161162 } ;
162163
163- return marked . parser ( ast , {
164+ const html = marked . parser ( ast , {
164165 highlight ( code , lang ) {
165166 return hljs . highlight ( lang ? lang : 'rust' , code ) . value ;
166167 } ,
167168 headerIds : true ,
168169 headerPrefix : '' ,
169170 renderer,
170171 } ) ;
172+ document . dispatchEvent ( new Event ( 'htmlbuilt' ) ) ;
173+ return html ;
171174 }
172175 } ,
173176 created : async function ( ) {
178181 . filter ( tag => tag . startsWith ( 'v' ) ) ;
179182 this . versionOptions = this . versionOptions . concat ( tagOptions ) ;
180183 } ,
181- mounted ( ) {
184+ updated : function ( ) {
182185 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+ } ) ;
187193 }
188194 } ) ;
189195 const extractDepthOnes = ( ast ) => {
You can’t perform that action at this time.
0 commit comments