import { GetStaticProps, GetStaticPaths, NextPage } from 'next' import { MDXRemote } from 'next-mdx-remote' import date from 'date-and-time' import { Head } from 'components/Head' import { Header } from 'components/Header' import { Footer, FooterProps } from 'components/Footer' import type { Post } from 'utils/blog' interface BlogPostPageProps extends FooterProps { post: Post } const BlogPostPage: NextPage = (props) => { const { version, post } = props return ( <> {post.frontmatter.title} {date.format(new Date(post.frontmatter.publishedOn), 'DD/MM/YYYY')} ) => { if (props.href?.startsWith('#') ?? false) { return } return ( ) } }} /> > ) } export const getStaticProps: GetStaticProps = async ( context ) => { const slug = context?.params?.slug const { getPostBySlug } = await import('utils/blog') const post = await getPostBySlug(slug) if (post == null || (post != null && !post.frontmatter.isPublished)) { return { redirect: { destination: '/404', permanent: false } } } const { readPackage } = await import('read-pkg') const { version } = await readPackage() return { props: { version, post } } } export const getStaticPaths: GetStaticPaths = async () => { const { getPosts } = await import('utils/blog') const posts = await getPosts() return { paths: posts.map((post) => { return { params: { slug: post.slug } } }), fallback: false } } export default BlogPostPage
{date.format(new Date(post.frontmatter.publishedOn), 'DD/MM/YYYY')}