This repository was archived by the owner on Feb 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathindex.tsx
More file actions
101 lines (92 loc) · 3.41 KB
/
Copy pathindex.tsx
File metadata and controls
101 lines (92 loc) · 3.41 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import Link from 'next/link'
import React, { Fragment } from 'react'
import type { Post } from '../../../payload/payload-types'
import { Gutter } from '../../_components/Gutter'
import { Media } from '../../_components/Media'
import RichText from '../../_components/RichText'
import { formatDateTime } from '../../_utilities/formatDateTime'
import classes from './index.module.scss'
export const PostHero: React.FC<{
post: Post
}> = ({ post }) => {
const {
id,
categories,
meta: { description, image: metaImage } = {},
populatedAuthors,
publishedDate,
title,
} = post
return (
<Fragment>
<Gutter className={classes.postHero}>
<div className={classes.content}>
<div className={classes.leader}>
<div className={classes.categories}>
{categories?.map((category, index) => {
const { title: categoryTitle } = category
const titleToUse = categoryTitle || 'Untitled category'
const isLast = index === categories.length - 1
return (
<Fragment key={index}>
{titleToUse}
{!isLast && <Fragment>, </Fragment>}
</Fragment>
)
})}
</div>
</div>
<h1 className={classes.title}>{title}</h1>
<p className={classes.meta}>
{populatedAuthors && (
<Fragment>
{'By '}
{populatedAuthors.map((author, index) => {
const { name } = author
const isLast = index === populatedAuthors.length - 1
const secondToLast = index === populatedAuthors.length - 2
return (
<Fragment key={index}>
{name}
{secondToLast && populatedAuthors.length > 2 && <Fragment>, </Fragment>}
{secondToLast && populatedAuthors.length === 2 && <Fragment> </Fragment>}
{!isLast && populatedAuthors.length > 1 && <Fragment>and </Fragment>}
</Fragment>
)
})}
</Fragment>
)}
{publishedDate && (
<Fragment>
{' on '}
{formatDateTime(publishedDate)}
</Fragment>
)}
</p>
<div>
<p className={classes.description}>{`${description ? `${description} ` : ''}`}</p>
<p>
Disclaimer: This content is fabricated and for demonstration purposes only. To edit
this post,
<Link href={`${process.env.NEXT_PUBLIC_SERVER_URL}/admin/collections/posts/${id}`}>
navigate to the admin dashboard
</Link>
.
</p>
</div>
</div>
<div className={classes.media}>
<div className={classes.mediaWrapper}>
{!metaImage && <div className={classes.placeholder}>No image</div>}
{metaImage && typeof metaImage !== 'string' && (
<Media fill imgClassName={classes.image} priority resource={metaImage} />
)}
</div>
{metaImage && typeof metaImage !== 'string' && metaImage?.caption && (
<RichText className={classes.caption} content={metaImage.caption} />
)}
</div>
</Gutter>
</Fragment>
)
}