I’m trying to customize the preview in Netlify CMS for my blog. I’ve just added a tags field to my config.yml, which is just a comma-separated list of tags for a blog post. I’m having trouble, however, in displaying those tags. I assume there’s something here that’s more tricky because of immutable.js? Here’s what I have, which I know is probably wrong:
this.props.widgetsFor('tags').map(function(tag, index) {
return h('span', {key: index}, tag)
})
However, with the tag test the above code returns:
datatestwidgets
I just copied the map function from the documentation, not sure if that’s the way to go with a simple list without fields.
I’ve logged the object in the console, and there are two arrays, with the first being ['data','test']
. and the second being ['widgets']
. I’m unsure of how to access the actual tag. Doing something like tag[0][1]
doesn’t seem to work because the arrays might be in a Object of some sort. Does anyone have any ideas? I’m sure I’m doing something pretty basic the wrong way.
Just to be thorough, here are the corresponding lines from my config.yml. Everything else displays correctly:
collections:
- name: "post"
label: "Posts"
folder: "blog"
create: true
slug: "{{slug}}"
fields:
- {label: "Title", name: "title", widget: "string"}
- {label: "Description", name: "description", widget: "string"}
- {label: "Publish Date", name: "date", widget: "date"}
- {label: "Tags", name: "tags", widget: "list"}
- {label: "Body", name: "body", widget: "markdown"}