forked from timlrx/tailwind-nextjs-starter-blog
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPostBanner.tsx
78 lines (75 loc) · 2.83 KB
/
PostBanner.tsx
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { ReactNode } from 'react'
import Image from '@/components/Image'
import Bleed from 'pliny/ui/Bleed'
import { CoreContent } from 'pliny/utils/contentlayer'
import type { Blog } from 'contentlayer/generated'
import Comments from '@/components/Comments'
import Link from '@/components/Link'
import PageTitle from '@/components/PageTitle'
import SectionContainer from '@/components/SectionContainer'
import siteMetadata from '@/data/siteMetadata'
import ScrollTopAndComment from '@/components/ScrollTopAndComment'
interface LayoutProps {
content: CoreContent<Blog>
children: ReactNode
next?: { path: string; title: string }
prev?: { path: string; title: string }
}
export default function PostMinimal({ content, next, prev, children }: LayoutProps) {
const { slug, title, images } = content
const displayImage =
images && images.length > 0 ? images[0] : 'https://picsum.photos/seed/picsum/800/400'
return (
<SectionContainer>
<ScrollTopAndComment />
<article>
<div>
<div className="space-y-1 pb-10 text-center dark:border-gray-700">
<div className="w-full">
<Bleed>
<div className="relative aspect-[2/1] w-full">
<Image src={displayImage} alt={title} fill className="object-cover" />
</div>
</Bleed>
</div>
<div className="relative pt-10">
<PageTitle>{title}</PageTitle>
</div>
</div>
<div className="prose max-w-none py-4 dark:prose-invert">{children}</div>
{siteMetadata.comments && (
<div className="pb-6 pt-6 text-center text-gray-700 dark:text-gray-300" id="comment">
<Comments slug={slug} />
</div>
)}
<footer>
<div className="flex flex-col text-sm font-medium sm:flex-row sm:justify-between sm:text-base">
{prev && prev.path && (
<div className="pt-4 xl:pt-8">
<Link
href={`/${prev.path}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
aria-label={`Previous post: ${prev.title}`}
>
← {prev.title}
</Link>
</div>
)}
{next && next.path && (
<div className="pt-4 xl:pt-8">
<Link
href={`/${next.path}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
aria-label={`Next post: ${next.title}`}
>
{next.title} →
</Link>
</div>
)}
</div>
</footer>
</div>
</article>
</SectionContainer>
)
}