File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { allBlogs } from 'contentlayer/generated'
66import tagData from 'app/tag-data.json'
77import { genPageMetadata } from 'app/seo'
88import { Metadata } from 'next'
9+ import { notFound } from 'next/navigation'
910
1011export 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}
You can’t perform that action at this time.
0 commit comments