Access frontmatter via mdx #2280
Unanswered
devjiwonchoi
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Duplicate of #1508, and my issue was that while embedding mdx on mdx, the frontmatter is left behind, resulting in frontmatter = {}. Short answer for now: // theme.config.tsx
import { useConfig } from 'nextra-theme-docs'
// ...
main: ({ children }) => {
const { frontMatter } = useConfig()
return (
<>
<h1 className="nx-mt-2 nx-text-4xl nx-font-bold nx-tracking-tight">
{frontMatter.title}
</h1>
{children}
</>
)
},
// ... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently importing an mdx file into my mdx in pages.
I want to do something like:
into:
P.S. When I try to use
useConfig
, it gives me this:Assuming
useConfig
is only allowed insidetheme.config.tsx
.Beta Was this translation helpful? Give feedback.
All reactions