Skip to content

Commit 80bb673

Browse files
authored
Merge pull request #989 from ray-android/patch-2
Fix issue #988
2 parents 6b5287e + 30e77ed commit 80bb673

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/tags/[tag]/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { allBlogs } from 'contentlayer/generated'
66
import tagData from 'app/tag-data.json'
77
import { genPageMetadata } from 'app/seo'
88
import { Metadata } from 'next'
9+
import { notFound } from 'next/navigation'
910

1011
export async function generateMetadata({ params }: { params: { tag: string } }): Promise<Metadata> {
1112
const tag = decodeURI(params.tag)
@@ -37,5 +38,8 @@ export default function TagPage({ params }: { params: { tag: string } }) {
3738
const filteredPosts = allCoreContent(
3839
sortPosts(allBlogs.filter((post) => post.tags && post.tags.map((t) => slug(t)).includes(tag)))
3940
)
41+
if (filteredPosts.length === 0) {
42+
return notFound()
43+
}
4044
return <ListLayout posts={filteredPosts} title={title} />
4145
}

0 commit comments

Comments
 (0)