Next.js Discord

Discord Forum

Intercept route group?

Unanswered
Blanc de Hotot posted this in #help-forum
Open in Discord
Blanc de HototOP
version: next 13

hi folks, i have a folder structure like:
- static pages using markdown at: app/(static) with an mdx layout (compiles local markdown files)
- a CMS folder at app/site/[slug] that renders cms pages (server-side, requires data fetching)
these all share a root layout that has a header.

buuuut i want to create a route at app/embed/:whatever that can render either the static page or the CMS page with a new root layout that doesn't have a header. i was able to achieve the CMS pages at app/embed/data/[slug]

i've tried creating a folder like app/embed/(...)(static) to handle the static pages but it hasn't worked. am i doing something wrong?

3 Replies

Blanc de HototOP
would appreciate any examples that aren't in the docs as i've perused everything there including the nextgram repository (it doesn't cover my use case)
test cases would be like:
- the MDX page at app/(static)/careers loads at the route /careers using the root layout
- the CMS page at app/site/help loads at the route /site/help using the root layout
- the route /embed/careers and /embed/help uses its own root layout separate from the other two
Blanc de HototOP
hmm alternatively if there's a way for me to detect if the page is being served in an iframe i could use a different layout, but i don't think layout.tsx has that capability