From 30e77eda9a8ad70fb9389046abaf9e903c61f2cc Mon Sep 17 00:00:00 2001 From: ray-android <163275631+ray-android@users.noreply.github.com> Date: Wed, 31 Jul 2024 01:01:48 +0800 Subject: [PATCH] Fix issue #988 Fix Invalid Tag Page Returns Status 200 Instead of 404 #988 --- app/tags/[tag]/page.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/tags/[tag]/page.tsx b/app/tags/[tag]/page.tsx index d2cab3f96..94a3dd226 100644 --- a/app/tags/[tag]/page.tsx +++ b/app/tags/[tag]/page.tsx @@ -6,6 +6,7 @@ import { allBlogs } from 'contentlayer/generated' import tagData from 'app/tag-data.json' import { genPageMetadata } from 'app/seo' import { Metadata } from 'next' +import { notFound } from 'next/navigation' export async function generateMetadata({ params }: { params: { tag: string } }): Promise { const tag = decodeURI(params.tag) @@ -37,5 +38,8 @@ export default function TagPage({ params }: { params: { tag: string } }) { const filteredPosts = allCoreContent( sortPosts(allBlogs.filter((post) => post.tags && post.tags.map((t) => slug(t)).includes(tag))) ) + if (filteredPosts.length === 0) { + return notFound() + } return }