Giter Site home page Giter Site logo

next-contentful-starter's Introduction

Next + Contentful Starter

Netlify Status

This is a Next.js v10.6.0 starter project with Contentful and set up to be instantly deployed to Netlify!

Deploy to Netlify

(If you click this button, it will create a new repo for you that looks exactly like this one, and sets that repo up immediately for deployment on Netlify)

Getting Started

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

Installation options

Option one: One-click deploy

Deploy to Netlify

Option two: Manual clone

  1. Clone this repo: git clone https://github.com/cassidoo/next-contentful-starter.git
  2. Navigate to the directory and run npm run dev
  3. Make your changes
  4. Connect to Netlify manually (the netlify.toml file is the one you'll need to make sure stays intact to make sure the export is done and pointed to the right stuff)

next-contentful-starter's People

Contributors

cassidoo avatar dependabot[bot] 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

Watchers

 avatar  avatar  avatar  avatar

next-contentful-starter's Issues

Build fails at CONTENTFUL_ACCESS_TOKEN

Hi there @cassidoo, I just tried to deploy this repo on Netlify, but my build failed with the following error:

4:56:35 PM: > Build error occurred
4:56:35 PM: TypeError: Expected parameter accessToken
4:56:35 PM:     at Module.createClient (/opt/build/repo/node_modules/contentful/dist/contentful.node.js:7563:11)
4:56:35 PM:     at Module.RNiq (/opt/build/repo/.next/server/pages/index.js:151:44)
4:56:35 PM:     at __webpack_require__ (/opt/build/repo/.next/server/pages/index.js:23:31)
4:56:35 PM:     at Object.0 (/opt/build/repo/.next/server/pages/index.js:99:18)
4:56:35 PM:     at __webpack_require__ (/opt/build/repo/.next/server/pages/index.js:23:31)
4:56:35 PM:     at /opt/build/repo/.next/server/pages/index.js:91:18
4:56:35 PM:     at Object.<anonymous> (/opt/build/repo/.next/server/pages/index.js:94:10)
4:56:35 PM:     at Module._compile (internal/modules/cjs/loader.js:1138:30)
4:56:35 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
4:56:35 PM:     at Module.load (internal/modules/cjs/loader.js:986:32) {
4:56:35 PM:   type: 'TypeError'
4:56:35 PM: }

After cloning the repo and running locally, I found the source at utils/contentfulPost.js .

I was able to get the site working by adding the global variables NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN and NEXT_PUBLIC_CONTENTFUL_SPACE_ID within Site settings > Build & deploy > Environment > Environment variables.

Below is my suggested addition to the README with information on how to set these global variables after one-click deploy. Let me know if you approve and I'll create a pull request.

## Add Contentful Access Tokens

You will need to add Contentful access tokens as global variables in Netlify to successfully deploy your site. After creating an account with Contentful, you can add these tokens by navigating to **Site settings > Build & deploy > Environment > Environment variables** and adding the following:

NEXT_PUBLIC_CONTENTFUL_SPACE_ID = [your contentful space id]
NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN = [your contentful access token]

Cheers,
Reed

Command failed with exit code 1: npm run build && npm run export

8:42:54 AM: ────────────────────────────────────────────────────────────────
8:42:54 AM: "build.command" failed
8:42:54 AM: ────────────────────────────────────────────────────────────────
8:42:54 AM: ​
8:42:54 AM: Error message
8:42:54 AM: Command failed with exit code 1: npm run build && npm run export
8:42:54 AM: ​
8:42:54 AM: Error location
8:42:54 AM: In build.command from netlify.toml:
8:42:54 AM: npm run build && npm run export
8:42:54 AM: ​
8:42:54 AM: Resolved config
8:42:54 AM: build:
8:42:54 AM: command: npm run build && npm run export
8:42:54 AM: commandOrigin: config
8:42:54 AM: environment:
8:42:54 AM: - NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN
8:42:54 AM: - NEXT_PUBLIC_CONTENTFUL_SPACE_ID
8:42:54 AM: publish: /opt/build/repo/out
8:42:54 AM: plugins:
8:42:54 AM: - inputs: {}
8:42:54 AM: origin: ui
8:42:54 AM: package: '@netlify/plugin-nextjs'
8:42:55 AM: Caching artifacts
8:42:55 AM: Started saving node modules
8:42:55 AM: Finished saving node modules
8:42:55 AM: Started saving build plugins
8:42:55 AM: Finished saving build plugins
8:42:55 AM: Started saving yarn cache
8:42:55 AM: Finished saving yarn cache
8:42:55 AM: Started saving pip cache
8:42:55 AM: Finished saving pip cache
8:42:55 AM: Started saving emacs cask dependencies
8:42:55 AM: Finished saving emacs cask dependencies
8:42:55 AM: Started saving maven dependencies
8:42:55 AM: Finished saving maven dependencies
8:42:55 AM: Started saving boot dependencies
8:42:55 AM: Finished saving boot dependencies
8:42:55 AM: Started saving rust rustup cache
8:42:55 AM: Finished saving rust rustup cache
8:42:55 AM: Started saving go dependencies
8:42:55 AM: Finished saving go dependencies
8:42:57 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:42:57 AM: Creating deploy upload records
8:42:57 AM: Failing build: Failed to build site
8:42:57 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
8:42:57 AM: Finished processing build request in 1m8.175264239s

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.