import { InView } from "react-intersection-observer"; import { NextSeo, ArticleJsonLd } from "next-seo"; import { MDXRemote, MDXRemoteProps } from "next-mdx-remote"; import Content from "../../components/Content"; import PostMeta from "../../components/PostMeta"; import Comments from "../../components/Comments"; import * as mdxComponents from "../../lib/helpers/mdx-components"; import { getPostSlugs, compilePost } from "../../lib/helpers/posts"; import * as config from "../../lib/config"; import { articleJsonLd } from "../../lib/config/seo"; import { meJpg } from "../../lib/config/favicons"; import type { GetStaticProps, GetStaticPaths, InferGetStaticPropsType } from "next"; import type { PostWithSource, PostFrontMatter } from "../../types"; const Note = ({ frontMatter, source }: InferGetStaticPropsType) => { return ( <> {!frontMatter.noComments && ( {({ inView, ref }) => (
{inView && }
)}
)} ); }; export const getStaticProps: GetStaticProps> = async ({ params }) => { if (!params?.slug) { return { notFound: true, }; } const { frontMatter, source } = await compilePost(params.slug); return { props: { frontMatter, source, }, }; }; export const getStaticPaths: GetStaticPaths = async () => { // get the slug of each .mdx file in /notes const slugs = await getPostSlugs(); // map slugs into a static paths object required by next.js const paths = slugs.map((slug) => ({ params: { slug } })); return { paths, fallback: false, }; }; export default Note;