www/pages/posts/[post].tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

import Layout from '../../components/layout';
2022-10-05 03:41:59 +00:00
import { getAllPosts, getPost } from '../../lib/slug';
import ReactMarkdown from 'react-markdown';
import style from '../../styles/post.module.css';
function Post({ post }: any) { // eh
return (<>
2022-10-05 03:41:59 +00:00
<Layout removeContainer={true} name={post.title} title={post.title} ancestors={[{ name: 'Posts', path: 'posts' }]}>
{<div className={style.imageBlock}
style={{ backgroundImage:
post.cover ?
`url(/assets/images/${post.cover})` :
'linear-gradient(to bottom right, #565a0f, #08432c 15%, rgb(5, 39, 10) 40%, rgb(0, 22, 46) 80%)'
}}></div>}
2022-05-15 13:56:45 +00:00
<div className={style.spacer}></div>
<section className={`${style.block} block`}>
2022-10-05 03:41:59 +00:00
<div className='container'>
<ReactMarkdown>{post.content}</ReactMarkdown>
</div>
2022-05-15 13:56:45 +00:00
</section>
</Layout>
2022-04-27 09:10:49 +00:00
</>
);
}
export async function getStaticProps({ params }: any) {
2022-10-05 03:41:59 +00:00
const post = getPost(params.post);
return {
props: { post }
};
}
export async function getStaticPaths() {
const posts = getAllPosts();
return {
paths: posts.map((post: any) => {
return {
params: {
2022-10-05 03:41:59 +00:00
post: post.slug
}
}
}),
fallback: false
};
}
export default Post;