GatsbyJS blog and e-commerce shop selling shirts, creating using the Gatsby Default Starter (https://github.com/gatsbyjs/gatsby-starter-default).
- Uses gatsby-transformer-remark for parsing Markdown blog posts.
- Uses gatsby-remark-images for processing images in Markdown blog posts. Works similar to Gatsby Image processing where it automatically serves optimized images with lazy loading and reduced file sizes
- Uses Contentful Headless CMS as a content management system, and gatsby-source-contentful
- Uses SnipCart to manage shopping cart with gatsby-plugin-snipcart
- User authentication with netlify-identity-widget
Hosted Example: https://vigorous-ardinghelli-9b2e76.netlify.app
$ npm install
You will need the following accounts in order to set up this project:
- Netlify -> for deployment
- Contentful -> for product content management
- SnipCart -> for ecommerce cart
- Click on the Menu (hamburger icon) in the top-left corner
- Click on Create Project
- Select free Community project
- Click on Content model link in app bar
- Click on Add content type button
- Enter in Product to the Name field and click Create
- Click on the Add Field button and add the following fields:
- Type: Text; Name: name; Short text, exact search
- Type: Number; Name: price; Decimal
- Type: Media; Name: image; One file
- Type: Text; Name: description; Short text, exact search
- Type: Text; Name: slug; Short text, exact search
- Type: Boolean; Name: private
- Click the Content link in app bar
- Click the Add Product button
- Add your product details
- Click on Settings -> API Keys
- Click on Add API Key
- Add a name and save
- Take note of the Space ID, and Content Delivery API - access token (you will need them as environment variables)
- Click on the Test option in the app bar
- Click on Account
- Click on API Keys
- Save the Public Test API Key to your .env file, as described below
NOTE: See Deploy section for how to set up site on Netlify
- Click on the Identity tab
- Click the Enable Identity button
IMPORTANT: this will only work when deployed with Netlify
Create a .env file in the main project directory with the following variables:
CONTENTFUL_SPACE_ID=your_contentful_space_id
CONTENTFUL_ACCESS_TOKEN=your_contentful_content_delivery_api_access_token
SNIPCART_PUBLIC_API_KEY=your_snipcart_public_test_api_key
$ npm run format
$ npm start
OR:
$ npm run develop
Deployed to:
http://localhost:8000/
GraphiQL:
http://localhost:8000/___graphql/
$ npm run build
OR:
$ gatsby build
Run production build locally:
$ gatsby serve
Deployed to:
http://localhost:9000/
- Log in to Netlify -> https://www.netlify.com
- Click on the New site from Git button
- Click on your hosting provider
- You will need to setup Netlify on your hosting provider, and give Netlify access to the repository you want to deploy
- Select the repository you want to deploy
- Click on the Show Advanced button to put in environment variables
- Put in the environment variables listed about
- Click Deploy Site button