Skip to content

Commit 93c2e65

Browse files
aszenzcalebcartwright
authored andcommitted
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.
1 parent 5fe47c8 commit 93c2e65

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/index.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@
7979
<script>
8080
const RusfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
8181
const UrlHash = window.location.hash.replace(/^#/, '');
82+
const queryParams = new URLSearchParams(window.location.search);
83+
const searchParam = queryParams.get('search');
84+
const searchTerm = null !== searchParam ? searchParam : '';
8285
new Vue({
8386
el: '#app',
8487
data: {
8588
aboutHtml: '',
8689
configurationAboutHtml: '',
8790
configurationDescriptions: [],
88-
searchCondition: UrlHash,
91+
searchCondition: searchTerm,
8992
shouldStable: false,
9093
version: 'master',
9194
oldVersion: undefined,
@@ -126,7 +129,9 @@
126129
return marked.parser(ast, {
127130
highlight(code, lang) {
128131
return hljs.highlight(lang ? lang : 'rust', code).value;
129-
}
132+
},
133+
headerIds: true,
134+
headerPrefix: ''
130135
});
131136
}
132137
},

0 commit comments

Comments
 (0)