fix: back button error and view transition on ios, move scripts from layout to components

This commit is contained in:
radishzzz 2025-03-22 05:24:10 +00:00
parent 783fb958d5
commit d2ebe60778
4 changed files with 90 additions and 85 deletions

View file

@ -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>