blob: c0a6b68e73ebaf5cadf58aa3129eee6993270afc (
plain)
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
|
import PostMeta from '@components/PostMeta/PostMeta';
import { ArticleMeta } from '@ts/types/articles';
import { Cover } from '@ts/types/cover';
import Image from 'next/image';
import React, { ReactElement } from 'react';
import styles from './PostHeader.module.scss';
const PostHeader = ({
cover,
intro,
title,
meta,
}: {
cover?: Cover;
intro?: string | ReactElement;
meta?: ArticleMeta;
title: string;
}) => {
const getIntro = () => {
if (React.isValidElement(intro)) {
const Intro = () => intro;
return (
<div className={styles.intro}>
<Intro />
</div>
);
}
return (
intro && (
<div
className={styles.intro}
dangerouslySetInnerHTML={{ __html: intro }}
></div>
)
);
};
return (
<header className={styles.wrapper}>
<div className={styles.body}>
<h1 className={styles.title}>
{cover && (
<span className={styles.cover}>
<Image src={cover.sourceUrl} alt={cover.altText} layout="fill" />
</span>
)}
{title}
</h1>
{meta && <PostMeta kind="article" meta={meta} />}
{getIntro()}
</div>
</header>
);
};
export default PostHeader;
|