mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
fix: back button error and view transition on ios, move scripts from layout to components
This commit is contained in:
parent
783fb958d5
commit
d2ebe60778
4 changed files with 90 additions and 85 deletions
|
@ -13,3 +13,22 @@
|
|||
<path d="M16.6 1.9 4.3 12l12.3 10.1.3 1.6h.8l-.5-5.5h-.8l.1 2.5L6.6 12l9.9-8.7-.1 2.5h.8l.5-5.5h-.8z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<script>
|
||||
function setupBackButton() {
|
||||
document.getElementById('back-button')?.addEventListener('click', () => {
|
||||
if (document.referrer && document.referrer.includes(window.location.hostname)) {
|
||||
window.history.back()
|
||||
}
|
||||
else {
|
||||
const titleLink = document.getElementById('site-title-link') as HTMLAnchorElement
|
||||
if (titleLink) {
|
||||
titleLink.click()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setupBackButton()
|
||||
document.addEventListener('astro:after-swap', setupBackButton)
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue