| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | import { normalizeDate } from "@/lib/date"; | 
					
						
							| 
									
										
										
										
											2023-12-29 20:07:19 +08:00
										 |  |  | import { fontSourceSerifScreenCN } from "@/styles/font"; | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | import { TPostListItem } from "@/types/post-list"; | 
					
						
							|  |  |  | import { nanoid } from "nanoid"; | 
					
						
							|  |  |  | import Link from "next/link"; | 
					
						
							| 
									
										
										
										
											2023-12-29 19:55:54 +08:00
										 |  |  | import { TagBadge } from "./TagBadge"; | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const PostList = (props: { data: TPostListItem[] }) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div> | 
					
						
							|  |  |  |       {props.data.map((postListItem, index) => ( | 
					
						
							|  |  |  |         <div | 
					
						
							|  |  |  |           key={`post-list-${nanoid()}`} | 
					
						
							| 
									
										
										
										
											2023-12-29 20:07:19 +08:00
										 |  |  |           className={`${fontSourceSerifScreenCN.className} flex flex-col justify-center ${ | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  |             index !== props.data.length - 1 && "border-b" | 
					
						
							| 
									
										
										
										
											2024-01-06 20:53:18 +08:00
										 |  |  |           } border-gray-200 dark:border-gray-800 py-3`}
 | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  |         > | 
					
						
							|  |  |  |           <Link className="hover:text-gray-600 dark:hover:text-gray-400" href={`/blog/${postListItem.id}`}> | 
					
						
							|  |  |  |             <div className="flex-center flex flex-col py-2 "> | 
					
						
							|  |  |  |               <h3 className="mx-auto text-xl font-extrabold capitalize">{postListItem.frontMatter.title}</h3> | 
					
						
							|  |  |  |               {postListItem.frontMatter.subtitle && ( | 
					
						
							|  |  |  |                 <div className="mx-auto text-base font-semibold capitalize">{postListItem.frontMatter.subtitle}</div> | 
					
						
							|  |  |  |               )} | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |             <div className="text-center">{normalizeDate(postListItem.frontMatter.time)}</div> | 
					
						
							|  |  |  |             {postListItem.frontMatter.summary && ( | 
					
						
							|  |  |  |               <div className="flex my-1 justify-center"> | 
					
						
							|  |  |  |                 <p>{postListItem.frontMatter.summary}</p> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |           </Link> | 
					
						
							|  |  |  |           {postListItem.frontMatter.tags && ( | 
					
						
							|  |  |  |             <div className="my-2 flex justify-center"> | 
					
						
							|  |  |  |               {postListItem.frontMatter.tags.map((tagName) => ( | 
					
						
							| 
									
										
										
										
											2023-12-29 19:55:54 +08:00
										 |  |  |                 <TagBadge name={tagName} size="sm" key={`tags-${nanoid()}`} /> | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  |               ))} | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           )} | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       ))} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | }; |