Files
MyBlog-Next/src/layouts/Main.astro
T
Sat Naing ceb406314b refactor: improve semantic by replacing decorative hr with borders (#597)
Replace decorative usage of Hr component with borders to improve
semantic.

- remove Hr component
- replace decorative hr elements with borders
- introduce app-layout utility class
- update layout and spacing
- update docs about border css custom property
2026-01-04 20:24:34 +07:00

51 lines
1.2 KiB
Plaintext

---
import Breadcrumb from "@/components/Breadcrumb.astro";
import { SITE } from "@/config";
interface StringTitleProp {
pageTitle: string;
pageDesc?: string;
}
interface ArrayTitleProp {
pageTitle: [string, string];
titleTransition: string;
pageDesc?: string;
}
export type Props = StringTitleProp | ArrayTitleProp;
const { props } = Astro;
const backUrl = SITE.showBackButton ? Astro.url.pathname : "/";
---
<Breadcrumb />
<main data-backUrl={backUrl} id="main-content" class="app-layout pb-4">
{
"titleTransition" in props ? (
<h1 class="text-2xl font-semibold sm:text-3xl">
{props.pageTitle[0]}
<span transition:name={props.titleTransition}>
{props.pageTitle[1]}
</span>
</h1>
) : (
<h1 class="text-2xl font-semibold sm:text-3xl">{props.pageTitle}</h1>
)
}
<p class="mt-2 mb-6 italic">{props.pageDesc}</p>
<slot />
</main>
<script>
document.addEventListener("astro:page-load", () => {
const mainContent: HTMLElement | null =
document.querySelector("#main-content");
const backUrl = mainContent?.dataset?.backurl;
if (backUrl) {
sessionStorage.setItem("backUrl", backUrl);
}
});
</script>