about summary refs log tree commit diff
diff options
context:
space:
mode:
authorasrar <aszenz@gmail.com>2020-06-23 08:00:45 +0530
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2021-08-17 21:55:26 -0500
commitc5f1d9698e83fbbf59c97aa229804274daf4cc8c (patch)
treea43b6ccc40447b1c161a09a848f6058457fdcb22
parent1045c62ac141d98fa7c86deb36887a2a9f9b45f2 (diff)
downloadrust-c5f1d9698e83fbbf59c97aa229804274daf4cc8c.tar.gz
rust-c5f1d9698e83fbbf59c97aa229804274daf4cc8c.zip
Adds direct linking using header ids (#4272)
Separates out search and direct linking, uses header ids for direct linking and `?search=term` for filtering configurations.
Once the app mounts the page is scrolled to the current header set in the url hash.
-rw-r--r--docs/index.html9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/index.html b/docs/index.html
index cea224f40d7..c89c73d4cf7 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -79,13 +79,16 @@
         <script>
             const RusfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
             const UrlHash = window.location.hash.replace(/^#/, '');
+            const queryParams = new URLSearchParams(window.location.search);
+            const searchParam = queryParams.get('search');
+            const searchTerm = null !== searchParam ? searchParam : '';
             new Vue({
               el: '#app',
               data: {
                 aboutHtml: '',
                 configurationAboutHtml: '',
                 configurationDescriptions: [],
-                searchCondition: UrlHash,
+                searchCondition: searchTerm,
                 shouldStable: false,
                 version: 'master',
                 oldVersion: undefined,
@@ -126,7 +129,9 @@
                   return marked.parser(ast, {
                     highlight(code, lang) {
                       return hljs.highlight(lang ? lang : 'rust', code).value;
-                    }
+                    },
+                    headerIds: true,
+                    headerPrefix: ''
                   });
                 }
               },