gctGenerator/site/.vuepress/enhanceApp.js

26 lines
795 B
JavaScript
Raw Normal View History

2020-06-28 06:33:20 +09: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-29 00:35:18 +09:00
siteData, // site metadata
2020-06-28 06:33:20 +09:00
}) => {
2020-09-26 23:07:24 +09:00
if (typeof document === 'undefined') return;
document.onreadystatechange = () => {
if (document.readyState === 'complete') {
const { hash } = location;
const decoded = decodeURIComponent(hash);
const targetAnchor = document.querySelector(decoded) ?? document.querySelector(hash);
if (targetAnchor && targetAnchor.offsetTop) {
window.scrollTo({ top: targetAnchor.offsetTop, behavior: 'smooth' });
}
}
};
2020-06-29 00:35:18 +09:00
};