File tree Expand file tree Collapse file tree 4 files changed +27
-11
lines changed
Expand file tree Collapse file tree 4 files changed +27
-11
lines changed Original file line number Diff line number Diff line change 11import { MDXRemote } from 'next-mdx-remote/rsc' ;
2- import rehypePrettyCode from 'rehype-pretty-code' ;
3- import rehypeSlug from 'rehype-slug' ;
4- import remarkBreaks from 'remark-breaks' ;
5- import remarkGfm from 'remark-gfm' ;
2+
63import style from './style.module.scss' ;
74import { MDXInjectComponents } from './inject-components' ;
5+ import { MDXOption } from './mdx-option' ;
86type Props = {
97 content : string ;
108} ;
@@ -14,13 +12,7 @@ export default function MDXRenderer(props: Props) {
1412 < article className = { `${ style [ 'cgoing-markdown' ] } mb-40` } >
1513 < MDXRemote
1614 source = { props . content }
17- options = { {
18- parseFrontmatter : true ,
19- mdxOptions : {
20- remarkPlugins : [ remarkGfm , remarkBreaks ] ,
21- rehypePlugins : [ rehypePrettyCode , rehypeSlug ] ,
22- } ,
23- } }
15+ options = { MDXOption }
2416 components = { MDXInjectComponents }
2517 />
2618 </ article >
Original file line number Diff line number Diff line change 11import Icon from '@components/icon' ;
2+ import LoadRemoteUrl from './load-remote-url' ;
23
34export const MDXInjectComponents = {
45 Icon,
6+ LoadRemoteUrl,
57} ;
Original file line number Diff line number Diff line change 1+ import { compileMDX } from 'next-mdx-remote/rsc' ;
2+ import { MDXOption } from '../mdx-option' ;
3+ export default async function LoadRemoteUrl ( { url } : { url : string } ) {
4+ const source = await fetch ( url ) . then ( ( res ) => res . text ( ) ) ;
5+
6+ const { content } = await compileMDX < { title : string } > ( {
7+ source,
8+ options : MDXOption ,
9+ } ) ;
10+ return content ;
11+ }
Original file line number Diff line number Diff line change 1+ import rehypePrettyCode from 'rehype-pretty-code' ;
2+ import rehypeSlug from 'rehype-slug' ;
3+ import remarkBreaks from 'remark-breaks' ;
4+ import remarkGfm from 'remark-gfm' ;
5+ export const MDXOption = {
6+ parseFrontmatter : true ,
7+ mdxOptions : {
8+ remarkPlugins : [ remarkGfm , remarkBreaks ] ,
9+ rehypePlugins : [ rehypePrettyCode , rehypeSlug ] ,
10+ } ,
11+ } ;
You can’t perform that action at this time.
0 commit comments