-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy pathpost-header.tsx
More file actions
49 lines (47 loc) · 1.64 KB
/
post-header.tsx
File metadata and controls
49 lines (47 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Link from 'next/link';
import { Badge } from '@/components/ui/badge';
import { Clock, Calendar, Info } from 'lucide-react';
interface PostHeaderProps {
post: {
title: string;
date: string;
readingTime: string;
category: {
name: string;
slug: string;
};
author?: {
name: string;
slug: string;
};
};
hasAffiliateLinks?: boolean;
}
export function PostHeader({ post, hasAffiliateLinks = false }: PostHeaderProps) {
return (
<div className="mb-8">
<div className="flex flex-wrap items-center gap-2 mb-4">
<Badge variant="secondary">
<Link href={`/categories/${post.category.slug}`}>{post.category.name}</Link>
</Badge>
<div className="flex items-center text-sm text-muted-foreground">
<Calendar className="mr-1 h-4 w-4" />
<span>{post.date}</span>
</div>
<div className="flex items-center text-sm text-muted-foreground">
<Clock className="mr-1 h-4 w-4" />
<span>{post.readingTime}</span>
</div>
</div>
<h1 className="text-3xl md:text-4xl font-bold tracking-tight">{post.title}</h1>
{hasAffiliateLinks && (
<div className="mt-4 flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-200">
<Info className="h-4 w-4 mt-0.5 shrink-0" />
<span>
<strong>Disclosure:</strong> This post contains affiliate links. We may earn a commission when you purchase through links in this article.
</span>
</div>
)}
</div>
);
}