Next.js Discord

Discord Forum

Using Nextra

Unanswered
Μοχάμεντ posted this in #help-forum
Open in Discord
I am trying to use nextra but the app.tsx file they gave in docs doesnt seem to work and i dont understand what the error means.
import { generateStaticParamsFor, importPage } from 'nextra/pages'
import { useMDXComponents } from '../../../../mdx-components'

type Props = {
  params: {
    mdxPath: string[] // Change this to an array of strings
  }
}

export const generateStaticParams = generateStaticParamsFor('mdxPath')

// Metadata generation for the page
export async function generateMetadata(props: Props) {
  const params = await props.params
  const { metadata } = await importPage(params.mdxPath) // Ensure mdxPath is a string array
  return metadata
}

const Wrapper = useMDXComponents({})?.wrapper;


// Page component with the proper types for props and dynamic imports
export default async function Page(props: Props) {
  const params = await props.params
  const result = await importPage(params.mdxPath) // Ensure mdxPath is a string array
  const { default: MDXContent, toc, metadata } = result

  return (
    <Wrapper toc={toc} metadata={metadata}>
      <MDXContent {...props} params={params} />
    </Wrapper>
  )
}

2 Replies

Error:
Argument of type '{}' is not assignable to parameter of type '{ symbol?: keyof IntrinsicElements | FC<Omit<SVGProps<SVGSymbolElement>, "ref">> | undefined; object?: keyof IntrinsicElements | FC<...> | undefined; ... 176 more ...; img: FC<...>; }'.
  Type '{}' is missing the following properties from type '{ symbol?: keyof IntrinsicElements | FC<Omit<SVGProps<SVGSymbolElement>, "ref">> | undefined; object?: keyof IntrinsicElements | FC<...> | undefined; ... 176 more ...; img: FC<...>; }': code, a, blockquote, details, and 19 more.ts(2345)
At:
const Wrapper = useMDXComponents({})?.wrapper;