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') {
|
2021-04-01 06:06:05 +09:00
|
|
|
if (location.hash && location.hash.length > 0) {
|
|
|
|
const { hash } = location;
|
2020-09-26 23:07:24 +09:00
|
|
|
|
2021-04-01 06:06:05 +09: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 23:07:24 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-06-29 00:35:18 +09:00
|
|
|
};
|