We wrote out our posts in markdown. Next.js doesn't automatically render markdown how we want it, so we are going to install and use the package react-markdown
.
Instructor: [0:00] We want to be able to render Markdown in our posts. Currently, when we click to Genie by Mark Twain, we notice some of the text is not formatted. To do this, we use something called react-markdown. We'll go back home, and in our terminal, we'll stop our server, type yarn add react-markdown.
[0:23] Once react-markdown is installed, we'll start our server again with yarn dev, and go back to VS Code. Open our file explorer and open our Components, we'll open content.js. In content.js, at the top, we'll import ReactMarkdown from 'react-markdown.' We'll cut the children and say ReactMarkdown. I'll add some special formatting, dollar sign, and paste and save.
[1:09] Now, when we click to Genie, we see our content formatted. That is how we use React Markdown in Next.js 13.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!