Alexander Strakhov
Alexander Strakhov

Reputation: 403

GatsbyJS: How to store an array in a markdown file?

Suppose I have the following index.md in my Gatsby app:

---
title: "Names"
numberOfNames: "3"
---

Now I would like to add an array of separate names like "Alex", "Bill", "Jack" under "names" tag.

How would I represent that array in a markdown file so that later I could iterate over it in my .js file?

Upvotes: 10

Views: 6174

Answers (1)

Derek Nguyen
Derek Nguyen

Reputation: 11577

frontmatter use yaml syntax. You can declare an array like so:

names:
  - Alex
  - Ben
  - ...

or

names: ['Alex', 'Ben', ...]

Upvotes: 17

Related Questions