import { GetStaticPaths, GetStaticProps } from "next";
import fs from "fs";
import { ParsedUrlQuery } from "querystring";
import { BLOGS_PATH, getBlogContentBySlug } from "../../utils/markdown";
import { MarkdownRenderingResult } from "../../types/types";
import { MainLayout } from "../../layouts/MainLayout";
import Link from "next/link";
import { IoMdArrowRoundBack as BackIcon } from "react-icons/io";
import { PostHeader } from "../../components/PostHeader";
import { readingTime } from "../../utils/general";
import { StyledMarkdown } from "../../components/StyledMarkdown";
export const BlogArticle = ({ frontMatter, html }: MarkdownRenderingResult) => {
return (
);
};
interface BlogProps extends ParsedUrlQuery {
slug: string;
}
export const getStaticPaths: GetStaticPaths = async () => {
const paths = fs
.readdirSync(BLOGS_PATH)
.map((path) => path.replace(/\.mdx?$/, ""))
.map((slug) => ({ params: { slug } }));
return {
paths,
fallback: false,
};
};
export const getStaticProps: GetStaticProps = async ({
params,
}) => {
const markdownContent = getBlogContentBySlug(params?.slug as string);
return {
props: {
frontMatter: markdownContent.frontMatter,
html: markdownContent.content,
},
};
};
export default BlogArticle;