Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
import BaseLayout from "@layouts/BaseLayout.astro";

const rawPath = Astro.url.pathname;

const cleanPath =
rawPath !== "/" ? rawPath.replace(/\/$/, "") : rawPath;

const searchText =
cleanPath.split("/").filter(Boolean).pop() || "";
---
<BaseLayout title="404: Page Not Found">
<section class="flex flex-col gap-8 items-start max-w-none prose px-2 py-8">

<p>
Sorry, we couldn't find your exact page <code>{cleanPath}</code>.
</p>

<div class="flex flex-col gap-4">
<a class="btn" href={`/search/?term=${searchText}`}>
Search here for <code>{searchText}</code>
</a>

<span>or</span>

<a class="btn secondary" href="/">
go home
</a>
</div>

</section>
</BaseLayout>
4 changes: 3 additions & 1 deletion src/pages/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const getStaticPaths = async () => {
};

const { page } = Astro.props;
if (!page) {
return Astro.redirect("/404");
}
---

<TextDetailLayout page={page} />
Loading