on 40fbeae help sign in
urbit.org/components/PostPreview.js
30 lines 860 B history raw
1import Link from "next/link";
2import BackgroundImage from "./BackgroundImage";
3import { formatDate } from "../lib/lib";
5export default function PostPreview(props) {
6 const section = props?.section ? props.section : "blog";
7 return (
8 <div className={`cursor-pointer ${props.className}`}>
9 {props.title ? <h3 className="mb-2">{props.title}</h3> : null}
11 <Link
12 href={`/${section}/${props.post.slug}`}
13 key={`post-${props.post.slug}`}
14 >
15 <div>
16 <BackgroundImage
17 className="w-full h-96 rounded-lg"
18 src={props.post.extra.image || ""}
19 />
20 <p className="text-black mt-2">{props.post.title}</p>
21 <p className="text-gray">{formatDate(new Date(props.post.date))}</p>
22 </div>
23 </Link>
24 </div>
25 );
28PostPreview.defaultProps = {
29 className: "",
30};