From 6cd32df0eeadad3094cc35724961a4bbd5541eb0 Mon Sep 17 00:00:00 2001 From: Jewgeni Date: Sat, 5 Oct 2024 10:02:39 +0200 Subject: [PATCH] feat(blog): add redirect to 404 page if entry is not found This commit adds a redirect to the 404 page if the entry is not found. This ensures that users are directed to the appropriate page when accessing a non-existent blog entry. --- src/pages/blog/[...slug].astro | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index a49565a..550292e 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -21,6 +21,11 @@ interface Props { } const { entry } = Astro.props as Props; + +if (!entry) { + return Astro.redirect('/404'); +} + const { Content } = await entry.render(); const components = { table: Table }; const {