Skip to content

Commit

Permalink
Adds direct linking using header ids (#4272)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aszenz authored and calebcartwright committed Aug 18, 2021
1 parent 1045c62 commit c5f1d96
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -126,7 +129,9 @@
return marked.parser(ast, {
highlight(code, lang) {
return hljs.highlight(lang ? lang : 'rust', code).value;
}
},
headerIds: true,
headerPrefix: ''
});
}
},
Expand Down

0 comments on commit c5f1d96

Please sign in to comment.