From 584625aea0328796cc6cebf4cf37be37a87f34b4 Mon Sep 17 00:00:00 2001 From: Andrea Date: Sun, 29 Sep 2024 13:37:02 +0200 Subject: [PATCH] refactor: code refactor --- app/utils/posts.server.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/utils/posts.server.ts b/app/utils/posts.server.ts index dcef720..e228247 100644 --- a/app/utils/posts.server.ts +++ b/app/utils/posts.server.ts @@ -12,8 +12,9 @@ type FrontMatter = { export const getMdxFile = async (file: string) => { const filePath = path.join(process.cwd(), `posts/${file}.mdx`); + const postContent = (await readFile(filePath)).toString(); return bundleMDX({ - source: (await readFile(filePath)).toString(), + source: postContent, mdxOptions(options) { return { rehypePlugins: [...(options.rehypePlugins ?? [])], @@ -44,8 +45,9 @@ export const findPosts = async () => { const posts: Post[] = []; for (const file of files.filter((file) => file.endsWith(".mdx"))) { const filePath = path.join(process.cwd(), `posts/${file}`); + const postContent = (await readFile(filePath)).toString(); const { frontmatter } = await bundleMDX({ - source: (await readFile(filePath)).toString(), + source: postContent, mdxOptions() { return { remarkPlugins: [