11import type { Metadata } from 'next'
2+ import { notFound } from 'next/navigation'
23import { getAllPostMeta } from '@/lib/library/registry'
34import { buildAuthorGraphJsonLd , buildAuthorMetadata , LIBRARY_SECTION } from '@/lib/library/seo'
45import { ContentAuthorPage } from '@/app/(landing)/components'
@@ -13,22 +14,24 @@ export async function generateMetadata({
1314 const { id } = await params
1415 const posts = ( await getAllPostMeta ( ) ) . filter ( ( p ) => p . authors . some ( ( a ) => a . id === id ) )
1516 const author = posts [ 0 ] ?. authors . find ( ( a ) => a . id === id )
17+ if ( ! author ) return { }
1618 return buildAuthorMetadata ( id , author )
1719}
1820
1921export default async function AuthorPage ( { params } : { params : Promise < { id : string } > } ) {
2022 const { id } = await params
2123 const posts = ( await getAllPostMeta ( ) ) . filter ( ( p ) => p . authors . some ( ( a ) => a . id === id ) )
2224 const author = posts [ 0 ] ?. authors . find ( ( a ) => a . id === id )
25+ if ( ! author ) notFound ( )
2326
2427 return (
2528 < ContentAuthorPage
2629 basePath = { LIBRARY_SECTION . basePath }
2730 sectionName = { LIBRARY_SECTION . name }
28- authorName = { author ? .name }
29- authorAvatarUrl = { author ? .avatarUrl }
31+ authorName = { author . name }
32+ authorAvatarUrl = { author . avatarUrl }
3033 posts = { posts }
31- graphJsonLd = { author ? buildAuthorGraphJsonLd ( author ) : undefined }
34+ graphJsonLd = { buildAuthorGraphJsonLd ( author ) }
3235 />
3336 )
3437}
0 commit comments