-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get frontmatter in v4 (client or server) #3554
Comments
Hi, where do you want to access frontmatter in mdx page or custom jsx component imported in mdx page? |
Custom JSX component that sits with the layout, just beneath the children, and renders its contents based on certain conditions from the frontmatter of the mdx page currently in view. E.g. I got this working in v3 making a wrapper component for |
I think similar we return
In the same way, we can return |
Yeah, that'd be amazing! |
Hi @Firgrep, I am finishing the Blogpost announcement for Nextra 4 RC.0 with all features and migration guide, so busy for now to add it I am planning to add this feat in Nextra 4 RC.1 For now, you can access const { normalizePagesResult } = useConfig()
console.log(normalizePagesResult.activePath.at(-1).frontMatter) Hope this unblock you for this moment ;) |
Hi @dimaMachina , thanks for the hotfix! ;) Really appreciate it! By the way, I've opened a new issue with regards to the bug, as I found another one and they seemed related. Ref #3567 |
Is your feature request related to a problem? Please describe.
useConfig()
handily exposed frontMatter, which allowed making components with conditions based on certain mdx file metadata.Describe the solution you'd like
A similar hook or function. I'm not sure if a replacement already exists but I can't find it.
The text was updated successfully, but these errors were encountered: