refactor: code refactor
This commit is contained in:
parent
b076be8fa7
commit
584625aea0
@ -12,8 +12,9 @@ type FrontMatter = {
|
|||||||
|
|
||||||
export const getMdxFile = async (file: string) => {
|
export const getMdxFile = async (file: string) => {
|
||||||
const filePath = path.join(process.cwd(), `posts/${file}.mdx`);
|
const filePath = path.join(process.cwd(), `posts/${file}.mdx`);
|
||||||
|
const postContent = (await readFile(filePath)).toString();
|
||||||
return bundleMDX<FrontMatter>({
|
return bundleMDX<FrontMatter>({
|
||||||
source: (await readFile(filePath)).toString(),
|
source: postContent,
|
||||||
mdxOptions(options) {
|
mdxOptions(options) {
|
||||||
return {
|
return {
|
||||||
rehypePlugins: [...(options.rehypePlugins ?? [])],
|
rehypePlugins: [...(options.rehypePlugins ?? [])],
|
||||||
@ -44,8 +45,9 @@ export const findPosts = async () => {
|
|||||||
const posts: Post[] = [];
|
const posts: Post[] = [];
|
||||||
for (const file of files.filter((file) => file.endsWith(".mdx"))) {
|
for (const file of files.filter((file) => file.endsWith(".mdx"))) {
|
||||||
const filePath = path.join(process.cwd(), `posts/${file}`);
|
const filePath = path.join(process.cwd(), `posts/${file}`);
|
||||||
|
const postContent = (await readFile(filePath)).toString();
|
||||||
const { frontmatter } = await bundleMDX<FrontMatter>({
|
const { frontmatter } = await bundleMDX<FrontMatter>({
|
||||||
source: (await readFile(filePath)).toString(),
|
source: postContent,
|
||||||
mdxOptions() {
|
mdxOptions() {
|
||||||
return {
|
return {
|
||||||
remarkPlugins: [
|
remarkPlugins: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user