import { GetStaticProps, NextPage } from 'next' import Link from 'next/link' import date from 'date-and-time' import { Head } from 'components/Head' import { Header } from 'components/Header' import { Footer, FooterProps } from 'components/Footer' import { ShadowContainer } from 'components/design/ShadowContainer' import type { PostMetadata } from 'utils/blog' const blogDescription = 'The latest news about my journey of learning computer science.' interface BlogPageProps extends FooterProps { posts: PostMetadata[] } const BlogPage: NextPage = (props) => { const { version, posts } = props return ( <> Blog {blogDescription} {posts.map((post, index) => { const postPublishedOn = date.format( new Date(post.frontmatter.publishedOn), 'DD/MM/YYYY' ) return ( {post.frontmatter.title} {postPublishedOn} {post.frontmatter.description} ) })} > ) } export const getStaticProps: GetStaticProps = async () => { const { readPackage } = await import('read-pkg') const { getPosts } = await import('utils/blog') const posts = await getPosts() const { version } = await readPackage() return { props: { version, posts } } } export default BlogPage
{blogDescription}
{postPublishedOn}
{post.frontmatter.description}