Files
MyBlog-Next/src/components/BackButton.astro
T
Sat Naing 5f72b93d92 refactor: extract redundant max-width into utility (#525)
* refactor: extract redundant max-width into utility

Extract redundant max-width into a universal tailwind
utility class. By doing so, the width of the layout
in different pages can be customized easily.

* docs: update docs for modifying `max-w-app` utility
2025-06-09 11:42:33 +07:00

38 lines
916 B
Plaintext

---
import IconChevronLeft from "@/assets/icons/IconChevronLeft.svg";
import LinkButton from "./LinkButton.astro";
import { SITE } from "@/config";
---
{
SITE.showBackButton && (
<div class="mx-auto flex w-full max-w-app items-center justify-start px-2">
<LinkButton
id="back-button"
href="/"
class="focus-outline mt-8 mb-2 flex hover:text-foreground/75"
>
<IconChevronLeft class="inline-block size-6" />
<span>Go back</span>
</LinkButton>
</div>
)
}
<script>
/* Update Search Praam */
function updateGoBackUrl() {
const backButton: HTMLAnchorElement | null =
document.querySelector("#back-button");
const backUrl = sessionStorage.getItem("backUrl");
if (backUrl && backButton) {
backButton.href = backUrl;
}
}
document.addEventListener("astro:page-load", updateGoBackUrl);
updateGoBackUrl();
</script>