fix anchor links

This commit is contained in:
alexfornuto 2021-07-27 15:06:35 -05:00
parent 9904849e8f
commit 74e75139d3

View file

@ -0,0 +1,18 @@
export default ({ router }) => {
if(typeof process === 'undefined' || process.env.VUE_ENV !== 'server') {
router.onReady(() => {
const { app } = router;
app.$once("hook:mounted", () => {
setTimeout(() => {
const { hash } = document.location;
if (hash.length > 1) {
const id = decodeURIComponent(hash.substring(1));
const element = document.getElementById(id);
if (element) element.scrollIntoView();
}
}, 500);
});
});
}
}