import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { Link, useLoaderData } from "@remix-run/react"; import { getMDXComponent } from "mdx-bundler/client/index.js"; import React from "react"; import { FaEdit } from "react-icons/fa"; import { Notbyai } from "~/components/Notbyai"; import { Title } from "~/components/Title"; import { useFormattedDate } from "~/hooks"; import { getMdxFile } from "~/utils/posts.server"; export const handle = { to: "/blog", text: "Go Back", }; export const loader = async ({ params }: LoaderFunctionArgs) => { const file = params.file; if (file == null) { throw new Response(null, { status: 400 }); } const data = await getMdxFile(file); return { ...data, file }; }; export const meta: MetaFunction = ({ data }) => { if (data == null) { return []; } const { frontmatter: { title, description }, } = data; return [ { title, }, { property: "og:title", content: title, }, { property: "description", content: description, }, ]; }; export default function Post() { const { code, frontmatter: { title, date }, file, } = useLoaderData(); const formattedDate = useFormattedDate(date); const MdxComponent = React.useMemo(() => getMDXComponent(code), [code]); return (
{title} ยท{" "} Go Back
Typo?
); }