feat: update back button logic

Instead of saving back url in the param, save the
back url info inside session.
This commit is contained in:
satnaing
2025-03-06 21:03:31 +07:00
committed by Sat Naing
parent 35429176e0
commit 79c7df45e5
4 changed files with 40 additions and 14 deletions
+11 -1
View File
@@ -22,7 +22,7 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
<Layout>
<Header />
<main id="main-content">
<main id="main-content" data-layout="index">
<section id="hero" class="pt-8 pb-6">
<h1 class="my-4 inline-block text-4xl font-bold sm:my-8 sm:text-5xl">
Mingalaba
@@ -119,3 +119,13 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
</main>
<Footer />
</Layout>
<script>
document.addEventListener("astro:page-load", () => {
const indexLayout = (document.querySelector("#main-content") as HTMLElement)
?.dataset?.layout;
if (indexLayout) {
sessionStorage.setItem("backUrl", "/");
}
});
</script>