on eef7fb1 help sign in
urbit.org/components/PostPreview.js
45 lines 1.3 kB 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="aspect-w-5 aspect-h-4 rounded-lg"
18 src={props.post.extra.image || ""}
19 />
21 <h4 className="mt-2">{props.post.title}</h4>
22 <div className="flex items-baseline mt-1">
23 {props.post.extra.author ? (
24 <div className="type-sub-bold mr-2">
25 {props.post.extra.author}
26 </div>
27 ) : null}
28 {props.post.extra.ship ? (
29 <div className="type-sub-bold text-gray font-mono">
30 {props.post.extra.ship}
31 </div>
32 ) : null}
33 </div>
34 <div className="text-gray type-sub mt-1">
35 {formatDate(new Date(props.post.date))}
36 </div>
37 </div>
38 </Link>
39 </div>
40 );
43PostPreview.defaultProps = {
44 className: "",
45};