File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export default async function compileMDX(
1616 mdx : string ,
1717 path : string | string [ ] ,
1818 params : { [ key : string ] : any }
19- ) : Promise < { Component : JSX . Element ; toc : any ; meta : any } > {
19+ ) : Promise < { content : JSX . Element ; toc : any ; meta : any } > {
2020 // Cache setup
2121 const store = new FileStore ( {
2222 root : `${ process . cwd ( ) } /node_modules/.cache/react-docs-mdx/` ,
@@ -70,21 +70,19 @@ export default async function compileMDX(
7070 } )
7171 ) ;
7272
73- // Parse frontmatter for metadata
7473 const { data : meta } = grayMatter ( mdx ) ;
7574
76- // Run the compiled code with the runtime and get the default export
7775 const { default : MDXContent } = await run ( code , {
7876 ...runtime ,
7977 baseUrl : import . meta. url ,
8078 } ) ;
8179
82- // Prepare TOC (you can process toc within the MDX or separately)
83- const { toc} = prepareMDX ( MDXContent ) ;
80+ const { toc, children} = prepareMDX (
81+ < MDXContent components = { { ...MDXComponents } } />
82+ ) ;
8483
85- // Return the ready-to-render React component
8684 return {
87- content : < MDXContent components = { { ... MDXComponents } } /> , // Replace {} with your custom components if needed
85+ content : children ,
8886 toc,
8987 meta,
9088 } ;
Original file line number Diff line number Diff line change @@ -34,15 +34,19 @@ function wrapChildrenInMaxWidthContainers(children) {
3434 let finalChildren = [ ] ;
3535 function flushWrapper ( key ) {
3636 if ( wrapQueue . length > 0 ) {
37- const Wrapper = 'MaxWidth' ;
38- finalChildren . push ( < Wrapper key = { key } > { wrapQueue } </ Wrapper > ) ;
37+ finalChildren . push (
38+ < div className = "max-w-4xl ms-0 2xl:mx-auto" key = { key } >
39+ { wrapQueue }
40+ </ div >
41+ ) ;
3942 wrapQueue = [ ] ;
4043 }
4144 }
4245 function handleChild ( child , key ) {
4346 if ( child == null ) {
4447 return ;
4548 }
49+
4650 if ( typeof child !== 'object' ) {
4751 wrapQueue . push ( child ) ;
4852 return ;
@@ -54,6 +58,7 @@ function wrapChildrenInMaxWidthContainers(children) {
5458 wrapQueue . push ( child ) ;
5559 }
5660 }
61+
5762 Children . forEach ( children , handleChild ) ;
5863 flushWrapper ( 'last' ) ;
5964 return finalChildren ;
You can’t perform that action at this time.
0 commit comments