-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
64 lines (50 loc) · 1.6 KB
/
index.tsx
File metadata and controls
64 lines (50 loc) · 1.6 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
import Preview from '@node-core/ui-components/Common/Preview';
import { useTranslations } from 'next-intl';
import FormattedTime from '#site/components/Common/FormattedTime';
import Link from '#site/components/Link';
import WithAvatarGroup from '#site/components/withAvatarGroup';
import { mapBlogCategoryToPreviewType } from '#site/util/blog';
import type { BlogCategory } from '#site/types';
import type { FC } from 'react';
import styles from './index.module.css';
type BlogPostCardProps = {
title: string;
category: BlogCategory;
description?: string;
authors?: Array<string>;
date?: string | Date;
slug?: string;
};
const BlogPostCard: FC<BlogPostCardProps> = ({
title,
slug,
category,
description,
authors = [],
date,
}) => {
const t = useTranslations();
const type = mapBlogCategoryToPreviewType(category);
return (
<article className={styles.container}>
<Link href={slug} aria-label={title}>
<Preview title={title} type={type} />
</Link>
<Link href={`/blog/${category}`} className={styles.subtitle}>
{t(`layouts.blog.categories.${category}`)}
</Link>
<Link href={slug} className={styles.title}>
{title}
</Link>
{description && <p className={styles.description}>{description}</p>}
<footer className={styles.footer}>
<WithAvatarGroup names={authors} size="medium" clickable={false} />
<div className={styles.author}>
{authors && <p>{authors.join(', ')}</p>}
{date && <FormattedTime date={date} />}
</div>
</footer>
</article>
);
};
export default BlogPostCard;