Begin rewrite to astro

This commit is contained in:
Timothy Pidashev
2024-09-06 19:44:15 -07:00
parent 93d9b3e014
commit 9d7414e0c9
51 changed files with 3862 additions and 3561 deletions

View File

@@ -1,30 +0,0 @@
import fs from "fs";
import path from "path";
import { compileMDX } from "next-mdx-remote/rsc";
import rehypeHighlight from "rehype-highlight";
import remarkGfm from "remark-gfm";
const contentDir = path.join(process.cwd(), "app/blog/posts");
export async function getBlogBySlug(slug) {
const filePath = path.join(contentDir, `${slug}.mdx`);
const source = fs.readFileSync(filePath, "utf8");
const { frontmatter, content } = await compileMDX({
source,
options: {
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [remarkGfm],
rehypePlugins: [rehypeHighlight],
},
},
});
return { frontmatter, content, slug };
}
export async function getAllBlogSlugs() {
const files = fs.readdirSync(contentDir);
return files.map(file => ({
slug: path.parse(file).name,
}));
}