2

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! :)

rosalindwills
  • 1,382
  • 13
  • 23

1 Answers1

0

Have you checked the Gatsby docs? Im assuming you have, but if you havent then i suggest starting there. A quick search reveals this: Sourcing from Netlify CMS

molebox
  • 585
  • 1
  • 8
  • 17
  • 1
    I have, yes. As I mentioned in my question - it doesn't really match my use case. The example the docs use are blog posts, which are represented as markdown files, with one Markdown-formatted body plus unformatted frontmatter. Instead, I have a YML (or JSON) file that contains Markdown-formatted values and I need to figure out how to parse that with Gatsby. – rosalindwills Jan 16 '20 at 19:24