import { type MDXRemoteSerializeResult } from "next-mdx-remote"; import { serialize } from "next-mdx-remote/serialize"; import { MDXRemote } from 'next-mdx-remote/rsc' // import { promises as fs } from "fs"; import { MdxContent } from "../../../components/mdx-content"; import { redirect } from "next/navigation"; type Frontmatter = { title: string; date: string; }; type Post = { serialized: MDXRemoteSerializeResult; frontmatter: TFrontmatter; }; export const runtime = "nodejs"; async function getPost(filepath: string): Promise> { // Read the file from the filesystem // const raw = await fs.readFile(filepath, "utf-8"); const raw = `# Hello World This is from Server Components! ` // Serialize the MDX content and parse the frontmatter const serialized = await serialize(raw, { parseFrontmatter: true, }); // Typecast the frontmatter to the correct type const frontmatter = serialized.frontmatter as Frontmatter; // Return the serialized content and frontmatter return { frontmatter, serialized, }; } export default async function PostsPage() { // Get the serialized content and frontmatter // const { serialized, frontmatter } = await getPost("content/post.mdx"); return redirect("/"); return (
{/*

{frontmatter.title}

Published {frontmatter.date}


qqqqqq */} {/* */}
); }