|
| 1 | +"use client"; |
| 2 | +import React from "react"; |
| 3 | +import { BlogContent } from "@/types/blog"; |
| 4 | +import { blogData } from "@/static/blog"; |
| 5 | +import Image from "next/image"; |
| 6 | +import PopularCard from "./PopularCard"; |
| 7 | +import { ArrowRight } from "lucide-react"; |
| 8 | +import Link from "next/link"; |
| 9 | + |
| 10 | +type Props = { |
| 11 | + content: BlogContent; |
| 12 | +}; |
| 13 | + |
| 14 | +const DetailContent = ({ content }: Props) => { |
| 15 | + const popularList = blogData.filter((item) => item.isPopular); |
| 16 | + |
| 17 | + return ( |
| 18 | + <div className="flex flex-col md:grid md:grid-cols-8 gap-4 px-4 py-4"> |
| 19 | + {/* left part - contents */} |
| 20 | + <div className="md:col-span-5 flex flex-col gap-4 py-4"> |
| 21 | + <p>{content.description}</p> |
| 22 | + |
| 23 | + {content.keyPerformance && ( |
| 24 | + <ul className="list-disc pl-5"> |
| 25 | + {content.keyPerformance.map((item, idx) => ( |
| 26 | + <li key={idx}>{item}</li> |
| 27 | + ))} |
| 28 | + </ul> |
| 29 | + )} |
| 30 | + |
| 31 | + {content.images && content.images.length > 0 && ( |
| 32 | + <div className="grid grid-cols-2 gap-2"> |
| 33 | + {content.images.map((img, idx) => ( |
| 34 | + <div key={idx} className="w-full h-42 relative"> |
| 35 | + <Image |
| 36 | + src={img} |
| 37 | + alt={`content-img-${idx}`} |
| 38 | + className="object-cover w-full h-full cursor-pointer" |
| 39 | + /> |
| 40 | + </div> |
| 41 | + ))} |
| 42 | + </div> |
| 43 | + )} |
| 44 | + |
| 45 | + {content.matchHighlight && content.matchHighlight.length > 0 && ( |
| 46 | + <div className=""> |
| 47 | + <h2 className="text-lg font-medium mb-2"> |
| 48 | + <span>📊</span> |
| 49 | + Match Highlights |
| 50 | + </h2> |
| 51 | + <ul className="list-disc pl-5"> |
| 52 | + {content.matchHighlight.map((highlight, idx) => ( |
| 53 | + <li key={idx}>{highlight}</li> |
| 54 | + ))} |
| 55 | + </ul> |
| 56 | + </div> |
| 57 | + )} |
| 58 | + </div> |
| 59 | + |
| 60 | + {/* right part - popular card */} |
| 61 | + <div className="md:col-span-3"> |
| 62 | + <div className="flex flex-col gap-2"> |
| 63 | + <div className="flex w-full justify-between px-2 items-center text-richBlack"> |
| 64 | + <p className="text-richBlack text-[1rem] font-bold">Most Viewed</p> |
| 65 | + <Link |
| 66 | + href={`/blog?filter=popular`} |
| 67 | + className="flex items-center gap-1" |
| 68 | + > |
| 69 | + <p className="text-richBlack text-[0.75rem]">View all</p> |
| 70 | + <ArrowRight className="text-richBlack w-4 h-4" /> |
| 71 | + </Link> |
| 72 | + </div> |
| 73 | + <div className="flex flex-col gap-2 px-2 py-4"> |
| 74 | + {popularList.slice(0, 3).map((list, idx) => { |
| 75 | + return ( |
| 76 | + <PopularCard |
| 77 | + key={idx} |
| 78 | + title={list.title} |
| 79 | + description={list.description} |
| 80 | + imageSrc={list.image} |
| 81 | + views={2456} |
| 82 | + /> |
| 83 | + ); |
| 84 | + })} |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + ); |
| 90 | +}; |
| 91 | + |
| 92 | +export default DetailContent; |
0 commit comments