import fs from "fs"; import path from "path"; import { GetStaticPaths, GetStaticProps, NextPage } from "next"; import ReactMarkdown from "react-markdown"; import matter from "gray-matter"; import { BlogMetadata } from "."; import gfm from "remark-gfm"; import gemoji from "remark-gemoji"; import { MarkdownComponentDefs } from "misc/MarkdownComponentDefs"; import { Box, chakra, Flex, Heading, Image, Text, VStack, } from "@chakra-ui/react"; interface Props { metadata: BlogMetadata; content: string; } const BlogPost: NextPage = ({ content, metadata: { author, author_avatar_url, cover_image, date, tags, title }, }) => { return ( {title} Avatar {author} {date} {title} {content} ); }; export default BlogPost; export const getStaticPaths: GetStaticPaths = async () => { const paths = fs.readdirSync("posts").map((file) => { return { params: { slug: file.replace(".md", ""), }, }; }); return { paths, fallback: false, }; }; export const getStaticProps: GetStaticProps = async (ctx) => { const { content, data } = matter( fs.readFileSync(path.join("posts", `${ctx.params?.slug}.md`), "utf-8") ); return { props: { content, metadata: data as BlogMetadata, }, }; };