Open Zain-ul-din opened 2 months ago
quick review from your video, i saw duplicated export default function RootLayout(){}
from app/layout.tsx
and app/docs/layout.tsx
might be the problem.
you should wrap any mdx content with shared layout.
layout: app/docs/layout.tsx
export default function MdxLayout({ children }: { children: React.ReactNode }) {
// Create any shared layout or styles here
return <div style={{ color: 'blue' }}>{children}</div>
}
page: app/docs/page.mdx
# Welcome to my MDX page!
[!NOTE] i know that you're trying to add some classes inside
docs/layout.tsx
, but you can't import another root-layout inside root-layout.
Link to the code that reproduces this issue
https://github.com/Zain-ul-din/mdx-templates
To Reproduce
I have no idea this is a feature or bug but it's not working as I want it to work. I'm using next js app router and my directory structure is following
I'm trying to add classes inside
docs/layout.tsx
body it's working on runtime but as I refresh the page it's being replaced by root layoutapp/layout.tsx
body classes.https://github.com/user-attachments/assets/42ac0b7d-1327-4d05-9452-8258b039265c
Current vs. Expected behavior
Nested layout classes should not be overridden by root layout.
Provide environment information
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Repo Link: https://github.com/Zain-ul-din/mdx-templates
Thank you in advance