loading...

Discussion on: Netlify CMS with Gatsby - Best Option with Some Quirks

Collapse
brattonross profile image
brattonross

I've been using Netlify CMS with Gatsby recently and have been running into exactly the issues that you describe here. I'm interested to know how you got local development working!

One thing that this setup has been forcing me to do is to write presentational and container components, since we can't use graphql queries in previews. This is beneficial in a way for me, as I'm using storybook as a way to "visually test" my components, so I can use those presentational components for both the previews and storybook stories.

Collapse
p4lm profile image
Henrik Sommerfeld Author

For local development I have to following code in cms.js:

const isDevelopment = process.env.NODE_ENV === 'development';

if (isDevelopment) {
  window.CMS_ENV = 'localhost_development';
  const fileSystemBackend = require('netlify-cms-backend-fs');
  CMS.registerBackend('file-system', fileSystemBackend);
}

config.yml then contains the following:

localhost_development:
  backend:
    name: file-system
    api_root: /api

Checkout the linked files or clone the entire repo to see how it fits together.