1
0
Fork 0
gctGenerator/site/.vuepress/enhanceApp.js

31 lines
861 B
JavaScript
Raw Normal View History

2020-06-27 23:33:20 +02:00
/**
* Client app enhancement file.
*
* https://v1.vuepress.vuejs.org/guide/basic-config.html#app-level-enhancements
*/
export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
2020-06-28 17:35:18 +02:00
siteData, // site metadata
2021-06-11 00:48:15 +02:00
isServer,
2020-06-27 23:33:20 +02:00
}) => {
2021-06-11 00:48:15 +02:00
if (isServer) return;
2020-09-26 16:07:24 +02:00
document.onreadystatechange = () => {
if (document.readyState === 'complete') {
2021-03-31 23:06:05 +02:00
if (location.hash && location.hash.length > 0) {
const { hash } = location;
2020-09-26 16:07:24 +02:00
2021-03-31 23:06:05 +02:00
const decoded = decodeURIComponent(hash);
const targetAnchor = document.querySelector(decoded) ?? document.querySelector(hash);
if (targetAnchor && targetAnchor.offsetTop) {
window.scrollTo({ top: targetAnchor.offsetTop, behavior: 'smooth' });
}
2020-09-26 16:07:24 +02:00
}
}
};
2020-06-28 17:35:18 +02:00
};