-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCardInterface.tsx
39 lines (37 loc) · 982 Bytes
/
CardInterface.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
import { Tag } from '@/components/blog/Tag';
import Link from 'next/link';
export function CardInterface({
card: { image, altTag, title, content, link, linkText, tagList },
styledComponents,
}) {
const LinkComponent = link?.startsWith('http') ? (
<a href={link} target='_blank' rel='noopener noreferrer'>
{linkText}
</a>
) : (
<Link href={link}>{linkText}</Link>
);
const S = styledComponents;
return (
<S.Card>
{image && (
<S.ImageWrapper>
<S.CardImage src={image} alt={altTag} fill />
</S.ImageWrapper>
)}
<S.Title title={title}>{title}</S.Title>
{tagList && tagList.length > 0 ? (
<S.TagContainer>
{tagList.slice(0, 8).map((tag, i) => (
<Tag key={i} text={tag} />
))}
</S.TagContainer>
) : null}
<S.ContentWrapper>
<p>
{content} {link && LinkComponent}
</p>
</S.ContentWrapper>
</S.Card>
);
}