Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 543
Alexander Strakhov Avatar asked Apr 01 '19 21:04

Alexander Strakhov


1 Answers

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

names:
  - Alex
  - Ben
  - ...

or

names: ['Alex', 'Ben', ...]
like image 155
Derek Nguyen Avatar answered Oct 11 '22 23:10

Derek Nguyen