2022-02-14 20:32:58 +00:00
|
|
|
import Layout from '../../components/layout';
|
|
|
|
import { useRouter } from 'next/router';
|
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';
|
|
|
|
import Image from 'next/image';
|
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
|
2022-02-14 20:32:58 +00:00
|
|
|
const router = useRouter();
|
2022-04-24 04:27:51 +00:00
|
|
|
return (<>
|
|
|
|
<Layout name={post.title} title={post.title} ancestors={[{ name: 'Posts', path: 'posts' }]}>
|
|
|
|
<div className={style.imageBlock} style={{ backgroundImage: post.cover ? `url(/assets/images/${post.cover})` : '' }}>
|
|
|
|
<div className={style.spacer}></div>
|
|
|
|
<section className={`${style.block} block`}>
|
|
|
|
<ReactMarkdown>{post.content}</ReactMarkdown>
|
|
|
|
</section>
|
|
|
|
<div className={style.spacer}></div>
|
|
|
|
</div>
|
2022-02-14 20:32:58 +00:00
|
|
|
</Layout>
|
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;
|