| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | import { normalizeDate } from "@/lib/date"; | 
					
						
							| 
									
										
										
										
											2024-09-26 16:48:47 +08:00
										 |  |  | import type { TPostListItem } from "@/types/docs.type"; | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | import { nanoid } from "nanoid"; | 
					
						
							|  |  |  | import Link from "next/link"; | 
					
						
							| 
									
										
										
										
											2024-01-09 16:48:48 +08:00
										 |  |  | import { Badge } from "../ui/badge"; | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export const PostList = (props: { data: TPostListItem[] }) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div> | 
					
						
							| 
									
										
										
										
											2024-01-09 16:48:48 +08:00
										 |  |  |       {props.data.map((postItem, index) => ( | 
					
						
							|  |  |  |         <Link className="cursor-pointer" href={`/blog/${postItem.id}`} key={`post-list-${nanoid()}`}> | 
					
						
							| 
									
										
										
										
											2024-01-08 18:18:21 +08:00
										 |  |  |           <div | 
					
						
							| 
									
										
										
										
											2024-01-09 16:48:48 +08:00
										 |  |  |             className={`flex flex-col justify-center ${ | 
					
						
							| 
									
										
										
										
											2024-01-08 18:18:21 +08:00
										 |  |  |               index !== props.data.length - 1 && "border-b" | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |             } border-gray-200 px-3 py-1 hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-900`}
 | 
					
						
							| 
									
										
										
										
											2024-01-08 18:18:21 +08:00
										 |  |  |           > | 
					
						
							| 
									
										
										
										
											2024-08-12 13:39:19 +08:00
										 |  |  |             <div className={"post-list-caption-font flex-col py-3"}> | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |               <div className="flex justify-center"> | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |                 <h3 className="mx-auto font-extrabold text-lg capitalize">{postItem.frontMatter.title}</h3> | 
					
						
							| 
									
										
										
										
											2024-01-08 18:18:21 +08:00
										 |  |  |               </div> | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |               <div className="flex justify-center"> | 
					
						
							|  |  |  |                 {postItem.frontMatter.subtitle && ( | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |                   <div className="mx-auto font-bold text-gray-700 text-sm capitalize dark:text-gray-300"> | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |                     {postItem.frontMatter.subtitle} | 
					
						
							|  |  |  |                   </div> | 
					
						
							|  |  |  |                 )} | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2024-01-15 11:44:48 +08:00
										 |  |  |             {postItem.frontMatter.summary && ( | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |               <div className={"flex justify-center content-font"}> | 
					
						
							| 
									
										
										
										
											2024-01-15 11:44:48 +08:00
										 |  |  |                 <p>{postItem.frontMatter.summary}</p> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             )} | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |             <div className="my-2 flex flex-wrap justify-between"> | 
					
						
							|  |  |  |               <div className="my-auto mr-2 flex h-6 flex-col justify-center text-center text-sm italic"> | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |                 <div className="my-auto">{normalizeDate(postItem.frontMatter.time)}</div> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |               {postItem.frontMatter.tags && ( | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |                 <div className="my-auto flex flex-wrap"> | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |                   {postItem.frontMatter.tags.map((tagName) => ( | 
					
						
							|  |  |  |                     <Badge | 
					
						
							| 
									
										
										
										
											2024-08-14 12:57:22 +08:00
										 |  |  |                       className="my-1 mr-1 text-gray-600 dark:text-gray-300" | 
					
						
							| 
									
										
										
										
											2024-04-03 22:08:27 +08:00
										 |  |  |                       key={`tags-${nanoid()}`} | 
					
						
							|  |  |  |                       variant={"secondary"} | 
					
						
							|  |  |  |                     > | 
					
						
							|  |  |  |                       {tagName} | 
					
						
							|  |  |  |                     </Badge> | 
					
						
							|  |  |  |                   ))} | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |               )} | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2024-01-08 18:18:21 +08:00
										 |  |  |           </div> | 
					
						
							|  |  |  |         </Link> | 
					
						
							| 
									
										
										
										
											2023-12-25 17:21:39 +08:00
										 |  |  |       ))} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | }; |