Skip to content

Commit

Permalink
Merge pull request rust-lang#3520 from rchaser53/improve-gh-page
Browse files Browse the repository at this point in the history
use filter by hash when first rendering
  • Loading branch information
topecongiro authored Apr 22, 2019
2 parents 31a6942 + 591b562 commit 1f61286
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@
</div>
<script>
const ConfigurationMdUrl = 'https://raw.githubusercontent.com/rust-lang/rustfmt/master/Configurations.md';
const UrlHash = window.location.hash.replace(/^#/, '');
new Vue({
el: '#app',
data() {
const configurationDescriptions = [];
configurationDescriptions.links = {}
configurationDescriptions.links = {};
return {
aboutHtml: '',
configurationAboutHtml: '',
searchCondition: '',
searchCondition: UrlHash,
configurationDescriptions,
shouldStable: false
}
Expand All @@ -102,7 +103,7 @@
return marked.parser(ast);
}
},
mounted: async function() {
created: async function() {
const res = await axios.get(ConfigurationMdUrl);
const {
about,
Expand All @@ -112,6 +113,16 @@
this.aboutHtml = marked.parser(about);
this.configurationAboutHtml = marked.parser(configurationAbout);
this.configurationDescriptions = configurationDescriptions;
},
mounted() {
if (UrlHash === '') return;
const interval = setInterval(() => {
const target = document.querySelector(`#${UrlHash}`);
if (target != null) {
target.scrollIntoView(true);
clearInterval(interval);
}
}, 100);
}
});
const extractDepthOnes = (ast) => {
Expand Down

0 comments on commit 1f61286

Please sign in to comment.