1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

feat(posts): add clean-code

This commit is contained in:
Divlo
2021-11-09 15:14:31 +01:00
parent bcb184e49c
commit 0bf89f4df5
8 changed files with 628 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import type { MDXRemoteSerializeResult } from 'next-mdx-remote'
import { serialize } from 'next-mdx-remote/serialize'
import remarkGfm from 'remark-gfm'
import remarkPrism from 'remark-prism'
import rehypeSlug from 'rehype-slug'
import matter from 'gray-matter'
export const postsPath = path.join(process.cwd(), 'posts')
@@ -63,7 +64,8 @@ export const getPostBySlug = async (
}
const source = await serialize(post.content, {
mdxOptions: {
remarkPlugins: [remarkGfm as any, remarkPrism]
remarkPlugins: [remarkGfm as any, remarkPrism],
rehypePlugins: [rehypeSlug as any]
}
})
return { ...post, source }