2022-02-14 20:32:58 +00:00
|
|
|
import Layout from '../../components/layout';
|
2022-04-23 23:03:43 +00:00
|
|
|
import { getAllPosts, getPost } from '../../util/slug';
|
2022-02-14 20:32:58 +00:00
|
|
|
import ReactMarkdown from 'react-markdown';
|
2022-04-24 04:27:51 +00:00
|
|
|
import style from '../../styles/post.module.css';
|
2022-02-14 20:32:58 +00:00
|
|
|
|
2022-04-24 04:27:51 +00:00
|
|
|
function Post({ post }: any) { // eh
|
|
|
|
return (<>
|
|
|
|
<Layout name={post.title} title={post.title} ancestors={[{ name: 'Posts', path: 'posts' }]}>
|
2022-05-15 13:56:45 +00:00
|
|
|
{post.cover
|
|
|
|
&& <div className={style.imageBlock} style={{ backgroundImage: `url(/assets/images/${post.cover})` }}></div>}
|
|
|
|
<div className={style.spacer}></div>
|
|
|
|
<section className={`${style.block} block`}>
|
|
|
|
<ReactMarkdown>{post.content}</ReactMarkdown>
|
|
|
|
</section>
|
|
|
|
<div className={style.spacer}></div>
|
2022-02-14 20:32:58 +00:00
|
|
|
</Layout>
|
2022-04-27 09:10:49 +00:00
|
|
|
|
2022-04-24 04:27:51 +00:00
|
|
|
</>
|
2022-02-14 20:32:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-24 04:27:51 +00:00
|
|
|
export async function getStaticProps({ params }: any) {
|
2022-02-14 20:32:58 +00:00
|
|
|
const post = getPost(params.page);
|
|
|
|
|
|
|
|
return {
|
2022-04-24 04:27:51 +00:00
|
|
|
props: { post }
|
2022-02-14 20:32:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
|
|
const posts = getAllPosts();
|
|
|
|
return {
|
2022-04-24 04:27:51 +00:00
|
|
|
paths: posts.map((post: any) => {
|
2022-02-14 20:32:58 +00:00
|
|
|
return {
|
|
|
|
params: {
|
|
|
|
page: post.slug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
fallback: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default Post;
|