-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
importPage() or importPage([]) doesn't work when in app/page.tsx but does in app/[[...mdxPath]].
I would expect both to work.
I'd prefer to use app/page.tsx to give me the ability to use index.md and add / specific elements/styling.
To Reproduce
- Add index.mdx
./content/index.mdx
---
title: Some title
---
Some index content- Add index page.tsx
./src/app/page.tsx
import { importPage } from 'nextra/pages';
import { useMDXComponents as getMDXComponents } from '@/mdx-components';
// @ts-expect-error -- Issue with nextra-theme-blog
const Wrapper = getMDXComponents().wrapper;
export default async function SiteIndexPage(props) {
const { default: MDXContent, toc, metadata } = await importPage([]);
return (
<Wrapper toc={toc} metadata={metadata}>
<MDXContent {...props} />
</Wrapper>
);
}- Attempt to load
localhost:3000
I see a 404 page with the following error logged:
- error [nextra] Error while loading { pathSegments: [] } Error: Cannot find module 'private-next-content-dir/undefined'
at async SiteIndexPage (src/app/page.tsx:8:49)
6 |
7 | export default async function SiteIndexPage(props) {
> 8 | const { default: MDXContent, toc, metadata } = await importPage([]);
| ^
9 |
10 | return (
11 | <Wrapper toc={toc} metadata={metadata}> {
code: 'MODULE_NOT_FOUND'
}
- Remove
app/page.tsxand addapp/[[...mdxPage]]/page.tsx
./src/app/[[...mdxPath]]/page.tsx (same as app/page.tsx)
import { importPage } from 'nextra/pages';
import { useMDXComponents as getMDXComponents } from '@/mdx-components';
// @ts-expect-error -- Issue with nextra-theme-blog
const Wrapper = getMDXComponents().wrapper;
export default async function SiteIndexPage(props) {
const { default: MDXContent, toc, metadata } = await importPage([]);
return (
<Wrapper toc={toc} metadata={metadata}>
<MDXContent {...props} />
</Wrapper>
);
}It works!
Expected behavior A clear and concise description of what you expected to
happen.
I would expect both app/page.tsx and app/[[...mdxPath]]/page.tsx to load content/index.md.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS 15.6 (24G84)
- Browser: Chrome 138.0.7204.184
- Node: 22.18.0
- Next.js: 15.4.5
- Nextra: 4.3.0
- nextra-theme-blog: 4.3.0
Thanks!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working