import { useMemo } from "react";
import { InView } from "react-intersection-observer";
import { NextSeo, ArticleJsonLd } from "next-seo";
import { escape } from "html-escaper";
import { getMDXComponent } from "mdx-bundler/client";
import Content from "../../components/Content";
import Meta from "../../components/notes/Meta";
import Comments from "../../components/notes/Comments";
import CustomCode from "../../components/code-block/Code";
import { getNote, getNoteSlugs } from "../../lib/parse-notes";
import * as config from "../../lib/config";
import type { GetStaticProps, GetStaticPaths } from "next";
import type { NoteType } from "../../types";
const Note = ({ frontMatter, mdxSource }: NoteType) => {
const MDXComponent = useMemo(() => getMDXComponent(mdxSource, { process }), [mdxSource]);
return (
<>
{frontMatter.noComments !== true && (
{({ inView, ref }) => (
)}
)}
>
);
};
export const getStaticProps: GetStaticProps = async ({ params }) => {
const { frontMatter, mdxSource } = await getNote(params.slug as string);
return {
props: {
frontMatter,
mdxSource,
},
};
};
export const getStaticPaths: GetStaticPaths = async () => {
const paths = getNoteSlugs().map((slug) => ({ params: { slug } }));
return {
paths,
fallback: false,
};
};
export default Note;