11import { format } from 'date-fns' ;
22import path from 'path' ;
33
4- import type { IContent } from '@/types/IArticleFrontmatter' ;
4+ import type { IPost } from '@/types/IArticleFrontmatter' ;
55import { AppConfig } from '@/utils/AppConfig' ;
66import { transformTitleForContentCard } from '@/utils/StringWidth' ;
77import type { Tags } from '@/utils/Tag' ;
88
99import { Tag } from './Tag' ;
1010
1111type IPostCardProps = {
12- instance : IContent ;
12+ instance : IPost ;
1313 contentCategory : string ;
1414 tags : Tags ;
1515} ;
1616
1717export const PostCard = ( props : IPostCardProps ) => {
18- const contentPath = props . instance . url ;
18+ const contentPath = path . join (
19+ '/' ,
20+ props . instance . collection ,
21+ props . instance . slug
22+ ) ;
1923
2024 return (
2125 < div className = "relative overflow-hidden rounded-md bg-slate-800" >
2226 < div className = "aspect-w-16 aspect-h-9" >
23- { props . instance . frontmatter . imgSrc && (
27+ { props . instance . data . imgSrc && (
2428 < img
2529 className = "h-full w-full object-cover object-center"
26- src = { path . join ( AppConfig . base , props . instance . frontmatter . imgSrc ) }
27- alt = { props . instance . frontmatter . imgSrc }
30+ src = { path . join ( AppConfig . base , props . instance . data . imgSrc ) }
31+ alt = { props . instance . data . imgSrc }
2832 loading = "lazy"
2933 />
3034 ) }
@@ -35,7 +39,7 @@ export const PostCard = (props: IPostCardProps) => {
3539 < div className = "py-1.5 px-3" >
3640 < a href = { contentPath } >
3741 < div >
38- { transformTitleForContentCard ( props . instance . frontmatter . title )
42+ { transformTitleForContentCard ( props . instance . data . title )
3943 . split ( '\\n' )
4044 . map ( ( t ) => (
4145 < span key = { t } className = "text-lg font-bold" >
@@ -44,16 +48,13 @@ export const PostCard = (props: IPostCardProps) => {
4448 </ span >
4549 ) ) }
4650 < span className = "align-middle text-xs text-gray-300 " >
47- { format (
48- new Date ( props . instance . frontmatter . pubDate ) ,
49- 'LLL d, yyyy'
50- ) }
51+ { format ( new Date ( props . instance . data . pubDate ) , 'LLL d, yyyy' ) }
5152 </ span >
5253 </ div >
5354 </ a >
5455 < div className = "mt-1 flex flex-wrap gap-2" >
55- { props . instance . frontmatter . tags &&
56- props . instance . frontmatter . tags . map ( ( tagName ) => (
56+ { props . instance . data . tags &&
57+ props . instance . data . tags . map ( ( tagName ) => (
5758 < Tag
5859 key = { tagName }
5960 name = { tagName }
0 commit comments