Nectar of the Programming Masses

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

gatsby-source-buttercms

2.0.0 • Public • Published

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(Object)

{
  allButterContentField {
    edges {
      node {
        key
        value
      }
    }
  }
}

Query Content Fields(Collection)

{
  allButterCollection {
    edges {
      node {
        key
        value{
          #Your collection fields
        }
      }
    }
  }
}

Query Pages

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

install

npm i gatsby-source-buttercms

Downloadsweekly downloads

13

version

2.0.0

license

GPL-3.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability