JulSeb42
JulSeb42

Reputation: 463

How can I display a frontmatter array with Next.js and Mdx?

I'm working on a project in Next.js where I have to display a bullet list from an array in frontmatter.

I managed to display the list, but the bullets are empty. How can I fix this?

This is my code:

Template.js:

{frontMatter.arrays.map(({ array }) => (
    <li>{array}</li>
))}

page.mdx:

arrays:
 - Content 1
 - Content 2

Result:

Result array

Upvotes: 0

Views: 2205

Answers (1)

Ray Purchase
Ray Purchase

Reputation: 762

Write your array like this in your frontmatter

arrays: ['item1', 'item2']

then to get the values:

{arrays && arrays.map((z) => (
    <p>{z}</p>
))}

Upvotes: 1

Related Questions