react Mdx renders even frontmatter data #2342
-
Hi, I'm new with mdx and I'm trying to render an mdx file in my React Vite app, but I noticed that it renders even the frontmatter metadata instead of hide them. I have a code like this, where I'm wrong ? vite.config.ts : import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import mdx from "@mdx-js/rollup";
export default defineConfig({
plugins: [mdx(), react()],
base: "/",
}); test-note.mdx : ---
title: Test Note
shortTitle: A shorter title
date: 1011-01-11
---
# Welcome to Note
_italic text_
This is the content of Note. Note.tsx : import TestNote from "../assets/notes/test-note.mdx";
export default function Note() {
return (
<div>
<TestNote />
</div>
);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Welcome @fiorins! 👋 |
Beta Was this translation helpful? Give feedback.
-
Thank you, in the mdx file I managed to do it but into my react component the import throws the error:
|
Beta Was this translation helpful? Give feedback.
Welcome @fiorins! 👋
I'd highly recommend reading the MDX documentation, there is a dedicated section on frontmatter which answers your question and more https://mdxjs.com/guides/frontmatter/