Skip to content

Commit 591b562

Browse files
committed
use filter by hash when first rendering
1 parent 31a6942 commit 591b562

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: docs/index.html

+14-3
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@
6767
</div>
6868
<script>
6969
const ConfigurationMdUrl = 'https://raw.githubusercontent.com/rust-lang/rustfmt/master/Configurations.md';
70+
const UrlHash = window.location.hash.replace(/^#/, '');
7071
new Vue({
7172
el: '#app',
7273
data() {
7374
const configurationDescriptions = [];
74-
configurationDescriptions.links = {}
75+
configurationDescriptions.links = {};
7576
return {
7677
aboutHtml: '',
7778
configurationAboutHtml: '',
78-
searchCondition: '',
79+
searchCondition: UrlHash,
7980
configurationDescriptions,
8081
shouldStable: false
8182
}
@@ -102,7 +103,7 @@
102103
return marked.parser(ast);
103104
}
104105
},
105-
mounted: async function() {
106+
created: async function() {
106107
const res = await axios.get(ConfigurationMdUrl);
107108
const {
108109
about,
@@ -112,6 +113,16 @@
112113
this.aboutHtml = marked.parser(about);
113114
this.configurationAboutHtml = marked.parser(configurationAbout);
114115
this.configurationDescriptions = configurationDescriptions;
116+
},
117+
mounted() {
118+
if (UrlHash === '') return;
119+
const interval = setInterval(() => {
120+
const target = document.querySelector(`#${UrlHash}`);
121+
if (target != null) {
122+
target.scrollIntoView(true);
123+
clearInterval(interval);
124+
}
125+
}, 100);
115126
}
116127
});
117128
const extractDepthOnes = (ast) => {

0 commit comments

Comments
 (0)