-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPost.tsx
57 lines (48 loc) · 1.43 KB
/
Post.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
import React from 'react';
import assert from 'assert';
import { MDXProvider } from '@mdx-js/react';
import BlogLayout from '../blog/Layout';
import BlogHeader from '../blog/Header';
import BlogContent from '../blog/Content';
import Seo from '../Seo';
import PostHeader from './markdown/Heading';
import CodeBlock from './markdown/CodeBlock';
import Link from './markdown/Link';
import styles from './Post.module.css';
import Footer from '../Footer';
const markdownComponents = {
a: Link,
pre: (props: React.HTMLProps<HTMLDivElement>) => <div {...props} />,
code: CodeBlock,
};
type PostProps = {
meta: {
title: string;
description: string;
date: string;
};
children: React.ReactNode;
};
const Post = ({ children, meta }: PostProps) => {
assert(meta.title, 'The post is missing a title!');
assert(meta.description, 'The post is missing a description!');
assert(meta.date, 'The post is missing a date!');
return (
<>
<Seo title={meta.title} description={meta.description} isPost />
<BlogLayout>
<BlogHeader isBlogPost />
<BlogContent>
<article>
<PostHeader title={meta.title} time={meta.date} />
<MDXProvider components={markdownComponents}>
<section className={styles.post}>{children}</section>
</MDXProvider>
</article>
</BlogContent>
<Footer />
</BlogLayout>
</>
);
};
export default Post;