@@ -4,13 +4,9 @@ import { format } from 'date-fns';
44import { Anchor , cn , useConfig } from '@theguild/components' ;
55import { AuthorId , authors } from '../../../authors' ;
66import { SocialAvatar } from '../../../components/social-avatar' ;
7+ import { BlogFrontmatter } from '../../blog/blog-types' ;
78
8- type Meta = {
9- authors : AuthorId [ ] ;
10- date : string ;
11- title : string ;
12- description : string ;
13- } ;
9+ type Meta = Pick < BlogFrontmatter , 'authors' | 'date' | 'title' | 'description' > ;
1410
1511export const ProductUpdateAuthors = ( {
1612 meta,
@@ -21,10 +17,15 @@ export const ProductUpdateAuthors = ({
2117} ) => {
2218 const date = meta . date ? new Date ( meta . date ) : new Date ( ) ;
2319
24- if ( meta . authors . length === 1 ) {
25- const author = authors [ meta . authors [ 0 ] as AuthorId ] ;
20+ const metaAuthors = ( Array . isArray ( meta . authors ) ? meta . authors : [ meta . authors ] ) . map ( author => {
21+ return typeof author === 'string' ? authors [ author as AuthorId ] : author ;
22+ } ) ;
23+
24+ if ( metaAuthors . length === 1 ) {
25+ const author = metaAuthors [ 0 ] ;
26+
2627 if ( ! author ) {
27- throw new Error ( `Author ${ meta . authors [ 0 ] } not found` ) ;
28+ throw new Error ( `Author ${ metaAuthors [ 0 ] } not found` ) ;
2829 }
2930
3031 return (
@@ -66,14 +67,9 @@ export const ProductUpdateAuthors = ({
6667 { format ( date , 'EEEE, LLL do y' ) }
6768 </ time >
6869 < div className = "my-5 flex flex-wrap justify-center gap-5" >
69- { meta . authors . map ( authorId => {
70- const author = authors [ authorId as AuthorId ] ;
71- if ( ! author ) {
72- throw new Error ( `Author ${ authorId } not found` ) ;
73- }
74-
70+ { metaAuthors . map ( author => {
7571 return (
76- < div key = { authorId } >
72+ < div key = { author . name } >
7773 < Anchor
7874 href = { author . link }
7975 title = { author . name }
0 commit comments