import React from "react"; import { BlogCardProps } from "./types"; import * as _NextLink from "next/link"; import { Text } from "@shared/components/text"; // CJS/ESM interop: next/link uses standard __esModule exports so this is safe. // next/image is intentionally avoided — its image-external.js uses the // `0 && (module.exports = {...})` tree-shaking hint which confuses webpack's // CJS→ESM interop and causes "got: object" errors in consuming apps. const Link = ((_NextLink as any).default ?? _NextLink) as typeof import("next/link").default; export const BlogCard: React.FC = ({ href, title, description, date, category, image, imageComponent: ImageComponent, asGrid = true, index, }: BlogCardProps) => { const parentClassName = asGrid ? "group relative flex h-full flex-col overflow-hidden rounded-card-lg bg-white shadow-drop transition-all duration-200 hover:-translate-y-0.5 hover:shadow-cardDrop" : `callout-card group relative w-full flex h-full flex-col overflow-hidden`; return (
{/* Image (hidden in list view) */} {asGrid && (
{image ? ( ImageComponent ? ( ) : ( {image.alt} ) ) : ( )} {/* Body */}
{/* Meta: category + date */}
{asGrid && {category}} {date && ( <> {asGrid && ( )} )}
{/* Title */} {title && ( {title} )} {/* Excerpt */} {description && ( {description} )}
{/* Fallback stretched link keeps the card navigable when no title link is rendered */} {!title && ( {category ?? "Read more"} )}
); }; export default BlogCard;