-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmdx-remote-test.tsx
42 lines (35 loc) · 955 Bytes
/
mdx-remote-test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import { serialize } from "next-mdx-remote/serialize";
import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote";
import Component1 from "../components/Component1";
const stringMDX = `---
Component1:
name: Mdx Rocks
---
<Component1 name={frontmatter.Component1.name} />
`;
const components = {
Component1,
};
interface MDXRemoteTestProps {
mdxSource: MDXRemoteSerializeResult<Record<string, unknown>, Record<string, unknown>>;
}
export default function MDXRemoteTest({ mdxSource }: MDXRemoteTestProps) {
return (
<>
<h1>Something about MDX:</h1>
<MDXRemote {...mdxSource} components={components} />
</>
);
}
export const getStaticProps = async () => {
const mdxSource = await serialize(stringMDX, {
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [],
rehypePlugins: [],
format: "mdx",
},
});
return { props: { mdxSource: mdxSource } };
};