"use client"
import { Icons } from "../icons"
import { Button } from "../ui/button"
import { LABELS } from "@/app/labels"
import { Article } from "@/lib/content"
import { cn } from "@/lib/utils"
import Image from "next/image"
import Link from "next/link"
interface ArticleInEvidenceCardProps {
article: Article
showReadMore?: boolean
size?: "sm" | "lg" | "xl"
variant?: "default" | "compact" | "xl"
className?: string
asLink?: boolean
titleClassName?: string
contentClassName?: string
showDate?: boolean
backgroundCover?: boolean
}
const AsLinkWrapper = ({
children,
href,
asLink,
className = "",
}: {
children: React.ReactNode
href: string
asLink: boolean
className?: string
}) => {
return asLink ? (
{children}
) : (
{children}
)
}
export const ArticleInEvidenceCard = ({
article,
showReadMore = false,
size = "lg",
variant = "default",
className,
asLink = false,
titleClassName = "",
contentClassName = "",
showDate = true,
backgroundCover = true,
}: ArticleInEvidenceCardProps) => {
const hideTldr = variant === "compact"
const formatDate = (dateString: string) => {
const date = new Date(dateString)
return date.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
})
}
const ArticleContent = ({ backgroundCover = true }: any) => {
return (
{article.date && showDate && (
{formatDate(article.date)}
)}
{article.title}
{(article?.authors ?? [])?.length > 0 && (
{article.authors?.join(", ")}
)}
{article.tldr && !hideTldr && (
{article.tldr}
)}
{(article?.tags ?? [])?.length > 0 && (
{article?.tags?.slice(0, 3)?.map((tag) => (
))}
)}
{showReadMore && (
)}
)
}
return (
{!backgroundCover && }
)
}