Code Monkey home page Code Monkey logo

gatsby-bigcommerce-netlify-cms-starter's Introduction

Gatsby + BigCommerce + Netlify CMS Starter

Note: This starter uses Gatsby v2.

Demo store

Accompanying tutorial blog post: Building a JAMstack Ecommerce Storefront with BigCommerce & Netlify

Accompanying overview video: Building e-commerce storefronts on the JAMstack

This version of the starter is meant to power a simple, single language storefront. If you are looking for something more complex, there is also a branch that supports multiple regions within a single storefront here.

Prerequisites

Setting up BigCommerce

The BigCommerce source plugin relies on API Keys. In this starter we are using the node project dotenv to access these variables. Make a copy of the SAMPLE.env file and fill in the variables from your BigCommerce API user details.

Note: You can sign up for a free trial on bigcommerce.com, which includes API access, if you don't already have an account. There is also a partner program which includes a sandbox account to play around in.

Once you have your API keys, do the following:

  • Install dependencies
    • yarn
  • Set up environment variables
    • cp SAMPLE.env .env
    • Enter your API credentials in .env file

Getting Started (Recommended - Netlify CLI)

Netlify CMS can run in any frontend web environment, but the quickest way to try it out is by running it on a pre-configured starter site with Netlify. Because the app requires credentials for the BigCommerce API, the easiest way to get started with a working deploy is via the Netlify CLI. To do so, run the following commands:

  • Link to your Netlify site
    • netlify link
  • Build
    • npm run build
  • Deploy to Netlify
    • netlify deploy

"One Click" Deploy

Alternative to the CLI, you can use the deploy button below to build and deploy your own copy of the repository. This is recommended if you have not already forked the repo (as it will make a copy of it).

Note: The initial deploy will fail, as you need to set build environment variables for your Netlify site

To set the variables:

  • Navigate to your Netlify site's "Build & Deploy" settings
  • Go to "Environment variables" > "Edit variables"
  • Enter the environment variables specified in "SAMPLE.env" and your BC API credentials

Deploy to Netlify

After clicking that button, you’ll authenticate with GitHub and choose a repository name. Netlify will then automatically create a repository in your GitHub account with a copy of the files from the template. Next, it will build and deploy the new site on Netlify, bringing you to the site dashboard when the build is complete. Next, you’ll need to set up Netlify’s Identity service to authorize users to log in to the CMS.

Access Locally

$ git clone https://github.com/[GITHUB_USERNAME]/[REPO_NAME].git
$ cd [REPO_NAME]
$ yarn
$ npm run start

To test the CMS locally, you'll need run a production build of the site:

$ npm run build
$ npm run serve

Media Libraries (installed, but optional)

Media Libraries have been included in this starter as a default. If you are not planning to use Uploadcare or Cloudinary in your project, you can remove them from module import and registration in src/cms/cms.js. Here is an example of the lines to comment or remove them your project.

import CMS from 'netlify-cms-app';
// import uploadcare from 'netlify-cms-media-library-uploadcare'
// import cloudinary from 'netlify-cms-media-library-cloudinary'

import AboutPagePreview from './preview-templates/AboutPagePreview';
import BlogPostPreview from './preview-templates/BlogPostPreview';
import ProductPagePreview from './preview-templates/ProductPagePreview';
import IndexPagePreview from './preview-templates/IndexPagePreview';

// CMS.registerMediaLibrary(uploadcare);
// CMS.registerMediaLibrary(cloudinary);

CMS.registerPreviewTemplate('index', IndexPagePreview);
CMS.registerPreviewTemplate('about', AboutPagePreview);
CMS.registerPreviewTemplate('products', ProductPagePreview);
CMS.registerPreviewTemplate('blog', BlogPostPreview);

Getting Started (Without Netlify)

$ gatsby new [SITE_DIRECTORY_NAME] https://github.com/netlify-templates/gatsby-starter-netlify-cms/
$ cd [SITE_DIRECTORY_NAME]
$ npm run build
$ npm run serve

Setting up the CMS

Follow the Netlify CMS Quick Start Guide to set up authentication, and hosting.

Debugging

Windows users might encounter node-gyp errors when trying to npm install. To resolve, make sure that you have both Python 2.7 and the Visual C++ build environment installed.

npm config set python python2.7
npm install --global --production windows-build-tools

Full details here

Purgecss

This plugin uses gatsby-plugin-purgecss and bulma. The bulma builds are usually ~170K but reduced 90% by purgecss.

Kudos

This is based on the Gatsby Netlify CMS Starter repo. Major kudos!

Photos in starter from various photographers: Aden Ardenrich Pixabay Artem Beliaikin Daria Shevtsova Aleksandar Pasaric Naim Benjelloun Kiara Coll Artem Beliaikin Eric Montanah Sanketh Rao Artem Beliaikin Jamie Diaz

CONTRIBUTING

Contributions are always welcome, no matter how large or small.

gatsby-bigcommerce-netlify-cms-starter's People

Contributors

austingreen avatar becomevocal avatar benaiah avatar charisewalraven avatar dbertella avatar ekoeryanto avatar erquhart avatar floydnoel avatar flppv avatar futuregerald avatar grantglidewell avatar hennessyevan avatar kalinchernev avatar krisaoe avatar kyleamathews avatar marcobiedermann avatar missmatsuko avatar neo avatar omrllm avatar phillc avatar rdela avatar renovate-bot avatar renovate[bot] avatar sakit0 avatar scottmathson avatar spences10 avatar talves avatar terrierscript avatar vincenavarro avatar zoltanveres avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gatsby-bigcommerce-netlify-cms-starter's Issues

Build fails due to GraphQL query error

Bug report

What is the current behavior?

Build Fails

If the current behavior is a bug, please provide the steps to reproduce.

  1. One Click Deploy via deploy to netlify button
  2. Update netlify environment variables
  3. Deploy fails with:
    3:45:28 PM: error #85907 GRAPHQL
    3:45:28 PM: There was an error in your GraphQL query:
    3:45:28 PM: - Unknown field 'images' on type '[BigCommerceProducts!]!'. Source: document ProductPage file: GraphQL request
    3:45:28 PM: File: src/templates/product-details.js

What is the expected behavior?

Deploy should complete successfully

Other relevant information:

Node.js version:
NPM/Yarn version:
Operating System:
Additional tools:

Multi-channel documentation?

Feature request

What is the expected behavior?
There should be documentation describing environment variables for multi-channel branch. Without this, I don't know where to start.

What is motivation or use case for adding/changing the behavior?
Using the multi-channel branch.

How should this be implemented in your opinion?
There should be documentation.

Are you willing to work on this yourself?
No.

gatsby-source-bigcommerce issue on multi-channel branch

Hey, I'm trying to setup and run development mode starter but it's getting error during development command:

success onPreBootstrap - 0.040 s
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v3/catalog/products?include=images,variants Using the get method
Starting Big Commerce Request
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v3/catalog/categories Using the get method
Starting Big Commerce Request
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v3/catalog/brands Using the get method
Starting Big Commerce Request
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v3/channels Using the get method
Starting Big Commerce Request
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v3/sites?limit=250 Using the get method
Starting Big Commerce Request
Request complete
Request complete
Request complete
Request complete
Request complete
Requesting Data from: https://api.bigcommerce.com/stores/nwulpmv4cm/v2/currencies.json Using the get method
Starting Big Commerce Request
Request complete

 ERROR #11321  PLUGIN

"gatsby-source-bigcommerce" threw an error while running the sourceNodes lifecycle:

Request returned error code: 403 and body:        $A
Hð^³ F® cvåMºL4ÎwoÚî>|ÞãN-تnxÜîWgÙf¸Á=y¥Äåb4

1Bl¡¤Ê¹½~ùɬêà}¹ҿòyY }ÔÜ%êG2v­C
                                 éwüÈ      Ú¤aiÇy~   ÿÿ ÆC%°



  Error: Request returned error code: 403 and body:        $A
  0E¯2dÓM5
våMºL4ÎwoÚî>|ÞãN-تnxÜîWgÙf¸Á=y¥Äåb4
 Hð^³ F® c
  1Bl¡¤Ê¹½~ùɬêà}¹ҿòyY }ÔÜ%êG2v­C éwüÈ Ú¤aiÇy~   ÿÿ ÆC%°   

  - request.js:93 IncomingMessage.res.on
    [gv-bc-store]/[gatsby-source-bigcommerce]/request.js:93:27

  - next_tick.js:63 process._tickCallback
    internal/process/next_tick.js:63:19


⠏ source and transform nodes
npm ERR! code ELIFECYCLE

I tested with postman, API points are working.

Problems with development environment setup

Hi, thanks for this starter! It has me really excited about BigCommerce compared to alternatives, and I'm hoping to switch to a JAMstack site.

I got a project set up from this starter by following the tutorial on Netlify, but I'm having some problems with the cart.

When I try to add something to the cart, nothing seems to happen in the browser. With a production build (local and on Netlify), I see no errors, but running the dev build locally I see the following errors in the terminal when I load http://localhost:8000/products/ and try to add something to the cart:

[HPM] Error occurred while trying to proxy request bigcommerce?endpoint=carts from localhost:8000 to http://localhost:9000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

[HPM] Error occurred while trying to proxy request bigcommerce?endpoint=catalog/products from localhost:8000 to http://localhost:9000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

[HPM] Error occurred while trying to proxy request bigcommerce?endpoint=carts/items from localhost:8000 to http://localhost:9000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

I'm also seeing an error in the browser console:

SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data"

That error seems to be because the fetchCart function is failing.

I'm not sure if I missed a setup step (I tried the tutorial twice, carefully doing every step from the beginning) or if something has changed since the tutorial was written. Two of the steps that I couldn't follow exactly were:

  1. The first time I tried to run the build script, there was an error with the GraphQL queries;
- Unknown field 'option_values' on type '[BigCommerceProductsVariants]'. Source: document `usersMeProjectsBcStorefrontSrcTemplatesProductDetailsJs2218306825` file: `GraphQL request`

File: src/templates/product-page.js

I had to remove option_values from the queries on src/templates/product-page.js and src/templates/product-details.js to get the site to build.

  1. The tutorial is working "under the assumption that you already have a Netlify site", which I didn't and the Netlify interface doesn't have an obvious way to create a Netlify site, so I ran the build script locally and manually uploaded the folder to create the site the first time before continuing with the tutorial.

Any help would be appreciated. Thank you!

Building Throws Error While Running the sourceNodes Lifecycle

Bug report

What is the current behavior?
The last thing it does prior to this Request complete after Starting Big Commerce Request
image

If the current behavior is a bug, please provide the steps to reproduce.
Add appropriate BigC '.env' values, then yarn build.

What is the expected behavior?
A successful build.

Other relevant information:

I also tried creating fresh credentials to see if that might be an issue, but the result was always the same. 😖

 System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.11.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 85.0.4183.102
    Safari: 13.1.2
  npmPackages:
    gatsby: ^2.1.34 => 2.15.28
    gatsby-image: ^2.0.23 => 2.2.23
    gatsby-plugin-netlify: ^2.0.6 => 2.1.17
    gatsby-plugin-netlify-cms: ^4.1.21 => 4.1.21
    gatsby-plugin-purgecss: ^4.0.0 => 4.0.1
    gatsby-plugin-react-helmet: ^3.0.4 => 3.1.10
    gatsby-plugin-sass: ^2.0.7 => 2.1.17
    gatsby-plugin-sharp: ^2.0.15 => 2.2.27
    gatsby-remark-copy-linked-files: ^2.0.7 => 2.1.23
    gatsby-remark-images: ^3.0.1 => 3.1.25
    gatsby-remark-relative-images: ^0.2.1 => 0.2.3
    gatsby-source-bigcommerce: ^0.3.3 => 0.3.3
    gatsby-source-filesystem: ^2.0.26 => 2.1.28
    gatsby-transformer-remark: ^2.3.4 => 2.6.26
    gatsby-transformer-sharp: ^2.1.9 => 2.2.19
  npmGlobalPackages:
    gatsby-cli: 2.12.99

Customer Login implementation

Feature request

What is the expected behavior?
We need to implement Login and registration forms from gatsby to bigcommerce.

What is motivation or use case for adding/changing the behavior?
Make fully headless integration with bigcommerce without depend on stencil only for checkout.

How should this be implemented in your opinion?
Any one have experience with netlify functions and bigcommerce API.

Are you willing to work on this yourself?
yes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.