Gatsby source plugin for building websites using Butter CMS as a data source.
Clone or download
jakelumetta Merge pull request #10 from marvinjude/patch-1
Fixes a bug on `allButterContent `
Latest commit b4fd418 Jan 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixes a bug on `allButterContent ` Jan 18, 2019
.babelrc Fix build Oct 18, 2018
.gitignore Add .npmignore file Nov 20, 2018
.npmignore Add .npmignore file Nov 20, 2018
README.md Fix wrong plural in README.md Dec 6, 2018
index.js add empty index.js Jul 26, 2017
package.json Make `pages` config field optional Dec 6, 2018
yarn.lock Add a few TODOs Oct 18, 2018

README.md

gatsby-source-buttercms

Source plugin for pulling blog posts, authors, categories, tags, and content fields into Gatsby from ButterCMS.

Install

npm install --save gatsby-source-buttercms

Usage

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-buttercms',
      options: {
        authToken: 'your_api_token',
        // Optional. Returns values for the supplied content field keys.
        contentFields: {
          keys: [
            'homepage_title',
            'homepage_headline'
          ],
          // Optional. Set to 1 to enable test mode for viewing draft content.
          test: 0
        },
        // Optional. Array of page slugs.
        pages: [
          'page_slug'
        ],
        // Optional. Array of page types.
        pageTypes: [
          'page_type'
        ]
      }
    }
  ]
}

Query Blog Posts

The plugin maps all JSON fields documented in the Butter CMS API Reference to GraphQL fields.

{
  allButterPost {
    edges {
      node {
        id
        date
        url
        created
        published
        author {
          first_name
          last_name
          email
          slug
          bio
          title
          linkedin_url
          facebook_url
          instagram_url
          pinterest_url
          twitter_handle
          profile_image
        }
        categories {
          name
          slug
        }
        tags {
          name
          slug
        }
        featured_image
        slug
        title
        body
        summary
        seo_title
        meta_description
        status
      }
    }
  }
}

Query Content Fields

{
  allButterContent {
    edges {
      node {
        key
        value
      }
    }
  }
}

Query Pages

{
  allButterPage {
    edges {
      node {
        slug
        page_type
        # Your page’s fields …
      }
    }
  }
}