From 46cea135728ab564b9ee1bcba15b6c9707b62db7 Mon Sep 17 00:00:00 2001 From: rakesh Date: Wed, 15 Apr 2026 01:29:50 +0530 Subject: [PATCH] feat(404): implement custom 404 page for missing text-detail routes - add 404.astro using existing layout structure - update [slug].astro to redirect when page is undefined - fix search link to respect trailingSlash: "always" --- src/pages/404.astro | 32 ++++++++++++++++++++++++++++++++ src/pages/[slug].astro | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/pages/404.astro diff --git a/src/pages/404.astro b/src/pages/404.astro new file mode 100644 index 0000000000..caea60a323 --- /dev/null +++ b/src/pages/404.astro @@ -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() || ""; +--- + +
+ +

+ Sorry, we couldn't find your exact page {cleanPath}. +

+ + + +
+
\ No newline at end of file diff --git a/src/pages/[slug].astro b/src/pages/[slug].astro index 99a86a6e61..2fdee7c689 100644 --- a/src/pages/[slug].astro +++ b/src/pages/[slug].astro @@ -26,6 +26,8 @@ export const getStaticPaths = async () => { }; const { page } = Astro.props; +if (!page) { + return Astro.redirect("/404"); +} --- -