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';
|
|
|
|
|
|
|
|
function Post({post} : any) { // eh
|
|
|
|
const router = useRouter();
|
|
|
|
return (
|
|
|
|
<Layout name={post.title} title={post.title} ancestors={[{name:'Posts', path: 'posts'}]}>
|
|
|
|
<section className='block'>
|
|
|
|
{post.cover ? <Image width={640} height={360} layout="intrinsic" src={`/assets/images/${post.cover}`} alt={`${post.title} Cover Image`} /> : ''}
|
|
|
|
<ReactMarkdown>{post.content}</ReactMarkdown>
|
|
|
|
</section>
|
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getStaticProps({params}: any) {
|
|
|
|
const post = getPost(params.page);
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {post}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
|
|
const posts = getAllPosts();
|
|
|
|
return {
|
|
|
|
paths: posts.map(post => {
|
|
|
|
return {
|
|
|
|
params: {
|
|
|
|
page: post.slug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
fallback: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default Post;
|