File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,21 @@ import Loader from "./Loader";
1414export interface Blogpost {
1515 _id : string ;
1616 title : string ;
17- author : string ;
17+ author : { _id : string ; email : string } ;
1818 blogpost : string ;
1919 createdAt : string ;
2020}
2121
2222interface BlogPostProps {
2323 title : string ;
24- author : string ;
24+ author : { _id : string ; email : string } ;
2525 createdAt : string ;
2626 blogpost : Blogpost ;
2727 setShowModal : ( value : boolean ) => void ;
2828}
2929
3030const BlogDetails = ( { blogpost } : BlogPostProps ) => {
31+ const { title, author, createdAt } = blogpost ;
3132 const { user } = useAuthContext ( ) ;
3233 const { dispatch } = useBlogpostsContext ( ) ;
3334 const headers = useMemo ( ( ) => {
@@ -90,13 +91,13 @@ const BlogDetails = ({ blogpost }: BlogPostProps ) => {
9091 { blog && (
9192 < article >
9293 < Typography variant = "h3" align = "left" >
93- { blogpost . title }
94+ { title }
9495 </ Typography >
9596 < Typography variant = "subtitle1" >
96- < strong > Written by { blogpost . author } </ strong >
97+ < strong > Written by { author . email } </ strong >
9798 </ Typography >
9899 < Typography variant = "subtitle2" >
99- { formatDistanceToNow ( new Date ( blogpost . createdAt ) , {
100+ { formatDistanceToNow ( new Date ( createdAt ) , {
100101 addSuffix : true ,
101102 } ) }
102103 </ Typography >
Original file line number Diff line number Diff line change @@ -44,8 +44,11 @@ const Home = ({ setShowModal }: HomeProps) => {
4444 { error && < div > { error } </ div > }
4545 { isPending && < Shimmer /> }
4646 { blogposts &&
47- blogposts . map ( ( blogpost : Blogpost ) => {
47+ blogposts
48+ . slice ( 0 , 3 )
49+ . map ( ( blogpost : Blogpost ) => {
4850 const { title, author, createdAt, _id } = blogpost ;
51+ console . log ( blogpost . author ) ;
4952 return (
5053 < BlogDetails
5154 key = { _id }
You can’t perform that action at this time.
0 commit comments