I'm working on developing a business site for a friend using GasbyJS and NetlifyCMS for content. I'm running into a bit of an issue determining how to use the CMS to maintain Markdown-formatted information that is not structured like a blog post, since that's where a lot of the tutorials out there work from.
My Netlify CMS config is as follows:
backend:
name: github
repo: my/repo
media_folder: static/assets
public_folder: assets
collections:
- label: 'Pages'
name: 'pages'
files:
- label: 'Home Page'
name: 'home'
file: 'content/home.yml'
fields:
- {
label: 'Home Banner Text',
name: home-banner-text,
widget: markdown,
}
- {
label: 'Home Acting Text',
name: home-acting-text,
widget: markdown,
}
- {
label: 'Home Costume Design Text',
name: home-costume-design-text,
widget: markdown,
}
- {
label: 'Home Modeling Text',
name: home-modeling-text,
widget: markdown,
}
Which produces a YML file at C:/path/to/my/site/content/home.yml
thus:
home-banner-text: 'Welcome to my site!'
home-acting-text: I **am an actor.** Click here to learn about my acting work.
home-costume-design-text: I am a costume designer. Click here to learn about my costume design work.
home-modeling-text: I am a model. Click here to learn about my modeling work.
This all seems fairly straightforward and, I think, logical -- the site is going to have a home page with four content sections on it, and I want the site owner to be able to modify each one with formatted content.
What I can't figure out is how to transform this in Gatsby once it's sourced via gatsby-source-filesystem
. There's a gatsby-transform-yaml
package, but it doesn't transform any Markdown in the YML field values to HTML, and while I've found a few packages that extend it by adding Markdown support, they all require some sort of prefix on any Markdown values (i.e. home-acting-text: md//I **am an actor.**
) in order to determine which ones should be parsed, and I can't figure out any way to get Netlify CMS to inject that.
It seems like I'll probably have to do some custom logic in gatsby-node.js
but I'm a little lost on where to start -- and this seems like a common enough use case that I wonder if I'm missing something.
Any guidance would be appreciated! :)