mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Handle scrolling to hash links when coming from an external page (#2513)
This commit is contained in:
parent
6cda48220d
commit
491992c1b5
1 changed files with 10 additions and 0 deletions
|
|
@ -98,6 +98,16 @@ parasails.registerPage('basic-documentation', {
|
|||
debug: false,
|
||||
});
|
||||
|
||||
// Handle hashes in urls when coming from an external page.
|
||||
if(window.location.hash){
|
||||
let possibleHashToScrollTo = _.trimLeft(window.location.hash, '#');
|
||||
let hashToScrollTo = document.getElementById(possibleHashToScrollTo);
|
||||
// If the hash matches a header's ID, we'll scroll to that section.
|
||||
if(hashToScrollTo){
|
||||
hashToScrollTo.scrollIntoView();
|
||||
}
|
||||
}
|
||||
|
||||
// // Alternative jQuery approach to grab `on this page` links from top of markdown files
|
||||
// let subtopics = $('#body-content').find('h1 + ul').children().map((_, el) => el.innerHTML);
|
||||
// subtopics = $.makeArray(subtopics);
|
||||
|
|
|
|||
Loading…
Reference in a new issue