@tenjuu99/blog 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -51,9 +51,22 @@ const transition = async (href) => {
|
|
|
51
51
|
script.remove()
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
window.scroll({top: 0, left: 0, behavior: 'instant'})
|
|
55
54
|
// set body
|
|
56
55
|
document.body = doc.getElementsByTagName('body')[0]
|
|
56
|
+
|
|
57
|
+
// Handle hash navigation
|
|
58
|
+
const url = new URL(href, window.location.origin)
|
|
59
|
+
if (url.hash) {
|
|
60
|
+
// Wait for next tick to ensure DOM is ready
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
const targetElement = document.querySelector(url.hash)
|
|
63
|
+
if (targetElement) {
|
|
64
|
+
targetElement.scrollIntoView({ behavior: 'instant' })
|
|
65
|
+
}
|
|
66
|
+
}, 0)
|
|
67
|
+
} else {
|
|
68
|
+
window.scroll({top: 0, left: 0, behavior: 'instant'})
|
|
69
|
+
}
|
|
57
70
|
// set header
|
|
58
71
|
document.title = doc.getElementsByTagName('title')[0].textContent
|
|
59
72
|
const canonical = document.head.querySelector('link[rel=canonical]')
|