How to use buttercms - 8 common examples

To help you get started, we’ve selected a few buttercms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ButterCMS / react-cms-blog-with-next-js / pages / categories.js View on Github external
import React from 'react'
import Butter from 'buttercms'

const butter = Butter('your_api_token')

export default class extends React.Component {
  static async getInitialProps ({ query }) {
    const resp = await butter.category.list()
    console.log(resp.data)
    return resp.data
  }
  render () {
    return (
      <div>
        {this.props.data.map((category, key) =&gt; {
          return (
            <div>
              <a href="{`/posts/category/${category.slug}`}">{category.name}</a>
            </div>
          )</div>
github ButterCMS / react-cms-blog-with-next-js / pages / case-study.js View on Github external
import React from 'react'
import Butter from 'buttercms'
import Head from 'next/head'

const butter = Butter('your_api_token')

export default class extends React.Component {
  static async getInitialProps ({ query }) {
    const resp = await butter.page.retrieve('customer_case_study', query.slug)
    return resp.data
  }
  render () {
    const product = this.props.data
    const { seo_title: seoTitle, customer_logo: customerLogo, headline, testimonial } = product.fields

    return (
      <div>
        
          <title>{seoTitle}</title>
        
</div>
github ButterCMS / react-ssr-example / hello.js View on Github external
import React from 'react';
import Butter from 'buttercms'
import Transmit from 'react-transmit';

const butter = Butter('b60a008584313ed21803780bc9208557b3b49fbb');

var Hello = React.createClass({
  render: function() {
    if (this.props.posts) {
      return (
        <div>
          {this.props.posts.data.map((post) =&gt; {
            return (
              <div>{post.title}</div>
            )
          })}
        </div>
      );
    } else {
      return <div>Loading...</div>;
    }
github ButterCMS / react-cms-blog-with-next-js / pages / case-studies.js View on Github external
import React from 'react'
import Butter from 'buttercms'

const butter = Butter('your_api_token')

export default class extends React.Component {
  static async getInitialProps ({ query }) {
    const resp = await butter.page.list('customer_case_study')
    return resp.data
  }
  render () {
    return (
      <div>
        {this.props.data.map((caseStudy, key) =&gt; {
          return (
            <div>
              <img width="40" height="40" src="{caseStudy.fields.customer_logo}">
              <a href="{`/case-studies/${caseStudy.slug}`}">{caseStudy.fields.headline}</a>
            </div>
          )</div>
github ButterCMS / react-cms-blog-with-next-js / pages / category.js View on Github external
import React from 'react'
import Butter from 'buttercms'
import Head from 'next/head'

const butter = Butter('your_api_token')

export default class extends React.Component {
  static async getInitialProps ({ query }) {
    const resp = await butter.category.retrieve(query.slug, {
      include: 'recent_posts'
    })
    return resp.data
  }
  render () {
    const category = this.props.data

    return (
      <div>
        
          <title>{category.name}</title>
        </div>
github ButterCMS / react-cms-blog-with-next-js / pages / faq.js View on Github external
import React, { Component } from 'react'
import Butter from 'buttercms'

const butter = Butter('your_api_token')

class Faq extends Component {
  static async getInitialProps () {
    const resp = await butter.content.retrieve([ 'faq_headline', 'faq_items' ])
    return resp.data.data
  }

  render () {
    return (
      <div>
        <h1>{this.props.faq_headline}</h1>

        <ul>
          {this.props.faq_items.map((item) =&gt; {
            return (
              <li></li></ul></div>
github ButterCMS / react-cms-blog-with-next-js / pages / index.js View on Github external
import React from 'react'
import Link from 'next/link'
import Butter from 'buttercms'

const butter = Butter('de55d3f93789d4c5c26fb07445b680e8bca843bd')

export default class extends React.Component {
  static async getInitialProps({ query }) {
    let page = query.page || 1;

    const resp = await butter.post.list({page: page, page_size: 10})
    return resp.data;
  }
  render() {
    const { next_page, previous_page } = this.props.meta;

    return (
      <div>
        {this.props.data.map((post, key) =&gt; {
          return (
            <div><a href="{`/post/${post.slug}`}">{post.title}</a></div></div>
github ButterCMS / react-cms-blog-with-next-js / pages / post.js View on Github external
import React from 'react'
import Butter from 'buttercms'
import Head from 'next/head'

const butter = Butter('de55d3f93789d4c5c26fb07445b680e8bca843bd')

export default class extends React.Component {
  static async getInitialProps({ query }) {
    const resp = await butter.post.retrieve(query.slug);  
    return resp.data;
  }
  render() {
    const post = this.props.data;

    return (
      <div>
        
          <title>{post.seo_title}</title>
          
          
        </div>

buttercms

ButterCMS API Client

MIT
Latest version published 3 days ago

Package Health Score

78 / 100
Full package analysis

Popular buttercms functions