From 79c7df45e5800ad21e5cfe793e79842803a66dba Mon Sep 17 00:00:00 2001 From: satnaing Date: Thu, 6 Mar 2025 21:03:31 +0700 Subject: [PATCH] feat: update back button logic Instead of saving back url in the param, save the back url info inside session. --- src/components/BackButton.astro | 14 +++++++++----- src/layouts/Main.astro | 20 +++++++++++++++++++- src/pages/archives/index.astro | 8 +------- src/pages/index.astro | 12 +++++++++++- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/components/BackButton.astro b/src/components/BackButton.astro index dc5e3f7..80b6662 100644 --- a/src/components/BackButton.astro +++ b/src/components/BackButton.astro @@ -19,15 +19,19 @@ import { SITE } from "@/config"; ) } - diff --git a/src/layouts/Main.astro b/src/layouts/Main.astro index fb30848..91f7151 100644 --- a/src/layouts/Main.astro +++ b/src/layouts/Main.astro @@ -1,5 +1,6 @@ --- import Breadcrumb from "@/components/Breadcrumb.astro"; +import { SITE } from "@/config"; interface StringTitleProp { pageTitle: string; @@ -15,10 +16,16 @@ interface ArrayTitleProp { export type Props = StringTitleProp | ArrayTitleProp; const { props } = Astro; + +const backUrl = SITE.showBackButton ? Astro.url.pathname : "/"; --- -
+
{ "titleTransition" in props ? (

@@ -34,3 +41,14 @@ const { props } = Astro;

{props.pageDesc}

+ + diff --git a/src/pages/archives/index.astro b/src/pages/archives/index.astro index 47b8cf4..72369e6 100644 --- a/src/pages/archives/index.astro +++ b/src/pages/archives/index.astro @@ -29,8 +29,6 @@ const months = [ "November", "December", ]; - -const backUrl = SITE.showBackButton ? `?from=${Astro.url.pathname}` : "/"; --- @@ -72,10 +70,7 @@ const backUrl = SITE.showBackButton ? `?from=${Astro.url.pathname}` : "/"; ) ) .map(({ data, id }) => ( - + ))} @@ -84,6 +79,5 @@ const backUrl = SITE.showBackButton ? `?from=${Astro.url.pathname}` : "/"; )) }
-