This link goes back to the first page, animating the link there with which you left that page.
And this is what the code looks like:
...<script> import {supportsViewTransitions} from 'astro:transitions/client';
let viewTransitionName: string; document.addEventListener('astro:before-preparation', (event) => { if (supportsViewTransitions) { const originalLoader = event.loader; event.loader = async () => { await originalLoader(); if (event.navigationType !== 'traverse') { viewTransitionName = getComputedStyle(event.sourceElement!).viewTransitionName; event.newDocument.querySelector('h1')!.style.viewTransitionName = viewTransitionName; history.replaceState({ ...history.state, viewTransitionName }, ''); } else { if (event.direction === 'back') { viewTransitionName = history.state.viewTransitionName; document.querySelector('h1')!.style.viewTransitionName = viewTransitionName; } else { event.newDocument.querySelector('h1')!.style.viewTransitionName = viewTransitionName; viewTransitionName = history.state.viewTransitionName; } } }; } });</script>
This is a forward link to page one.
Back to the previous page