|
1 | 1 | import { GetStaticPaths, GetStaticProps } from "next"; |
2 | | -import { MDXRemoteSerializeResult } from "next-mdx-remote"; |
3 | | -import { serialize } from "next-mdx-remote/serialize"; |
4 | | -import React from "react"; |
5 | | -import rehypeHighligh from "rehype-highlight"; |
| 2 | +import rehypeHighlight from "rehype-highlight"; |
6 | 3 | import rehypeUnwrapImages from "rehype-unwrap-images"; |
7 | 4 | import remarkGfm from "remark-gfm"; |
| 5 | +import { serialize, type SerializeResult } from "next-mdx-remote-client/serialize"; |
8 | 6 |
|
9 | 7 | import { ApiArticle } from "@/cms/api/ApiArticle"; |
10 | 8 | import { getNotesRepository } from "@/cms/repositories"; |
11 | 9 | import { Post } from "@/layouts/Post"; |
12 | 10 | import { isDevelopment } from "@/lib/env"; |
13 | 11 |
|
14 | | -interface NoteProps { |
15 | | - mdx: MDXRemoteSerializeResult; |
| 12 | +type NoteProps = { |
| 13 | + mdx: SerializeResult; |
16 | 14 | note: ApiArticle; |
17 | | -} |
| 15 | +}; |
18 | 16 |
|
19 | | -export default class Notes extends React.Component<NoteProps> { |
20 | | - public render() { |
21 | | - return <Post breadcrumbs={[{ label: "Notes", url: "/notes" }]} mdx={this.props.mdx} post={this.props.note} />; |
22 | | - } |
| 17 | +export default function Note(props: Readonly<NoteProps>) { |
| 18 | + return <Post breadcrumbs={[{ label: "Notes", url: "/notes" }]} mdx={props.mdx} post={props.note} />; |
23 | 19 | } |
24 | 20 |
|
25 | 21 | export const getStaticPaths: GetStaticPaths = async () => { |
@@ -47,10 +43,14 @@ export const getStaticProps: GetStaticProps<NoteProps> = async ({ params }) => { |
47 | 43 | props: { |
48 | 44 | note: note.toApiArticle({ cover: "https://codecoolture.com/static/notes/cover.jpg" }), |
49 | 45 |
|
50 | | - mdx: await serialize(note.getContent(), { |
51 | | - mdxOptions: { |
52 | | - rehypePlugins: [rehypeHighligh, rehypeUnwrapImages], |
53 | | - remarkPlugins: [remarkGfm], |
| 46 | + mdx: await serialize({ |
| 47 | + source: note.getContent(), |
| 48 | + |
| 49 | + options: { |
| 50 | + mdxOptions: { |
| 51 | + rehypePlugins: [rehypeHighlight, rehypeUnwrapImages], |
| 52 | + remarkPlugins: [remarkGfm], |
| 53 | + }, |
54 | 54 | }, |
55 | 55 | }), |
56 | 56 | }, |
|
0 commit comments