about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorrchaser53 <tayoshizawa29@gmail.com>2019-04-22 23:47:50 +0900
committerrchaser53 <tayoshizawa29@gmail.com>2019-04-22 23:50:44 +0900
commit591b562bcfd15783065d17e0bb7265df364d75ff (patch)
treea062f590b4f284d3e46017daf8c9140e17a02df8 /docs
parent31a69429aebafe6aeba5d28e5fa3088db78023ce (diff)
downloadrust-591b562bcfd15783065d17e0bb7265df364d75ff.tar.gz
rust-591b562bcfd15783065d17e0bb7265df364d75ff.zip
use filter by hash when first rendering
Diffstat (limited to 'docs')
-rw-r--r--docs/index.html17
1 files changed, 14 insertions, 3 deletions
diff --git a/docs/index.html b/docs/index.html
index 55c715526a6..2a12da3881f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -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
                 }
@@ -102,7 +103,7 @@
                   return marked.parser(ast);
                 }
               },
-              mounted: async function() {
+              created: async function() {
                 const res = await axios.get(ConfigurationMdUrl);
                 const { 
                   about,
@@ -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) => {