Skip to content

Commit

Permalink
feat(docs): Add "Sourcing from Contentful" (#8861)
Browse files Browse the repository at this point in the history
* Issue 8741: WIP
Copied over https://www.gatsbyjs.org/blog/2018-1-25-building-a-site-with-react-and-contentful/#what-is-contentful-why-choose-it I still need to remove/add what's needed

* Removing unuseful information from the original post!

* docs: clean up documentation and mention the usage of gatsby-source-contentful plugin

* Removed TODO list

* Tweaks
  • Loading branch information
alejandronanez authored and amberleyromo committed Oct 22, 2018
1 parent ccdf27c commit 8e27d72
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions docs/docs/sourcing-from-contentful.md
Expand Up @@ -2,7 +2,58 @@
title: Sourcing from Contentful
---

This is a stub. Help our community expand it.
## What is Contentful? Why choose it?

Please use the [Gatsby Style Guide](/docs/gatsby-style-guide/) to ensure your
pull request gets accepted.
Contentful is a headless Content Management System (CMS) that lets you organize your content into what could be called “modules,” or little bits of data that can be rearranged to appear nicely on mobile devices, tablets, computers, virtual reality devices (maybe someday?) and more.

Actually, the way Contentful handles bits of content means that you can push content out when new technology develops without having to redesign, rewrite, or rethink all of it for a new format.


## Prerequisites

This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [Quick Start guide](/docs), then come back.

## Pulling data in and pushing data out

If you have a JSON file with content in it, you could pull it into Contentful using [contentful-import](https://github.com/contentful/contentful-import). If you are creating new content, you don't need this and just create content straight in Contentful.

If you do create content directly in Contentful, make sure to name your fields in a way you can remember when you create GraphQL queries. If you use GraphiQL, it can suggest fields to you, but this will only help if the field names are clear and memorable.

As far as pushing data out to your site goes, we suggest to you to use this fantastic plugin [gatsby-source-contentful](https://www.npmjs.com/package/gatsby-source-contentful), to use it, you'd need to have the `spaceId` and the `accessToken` from contentful.

## Install

```bash
npm install --save gatsby-source-contentful
```

## How to use

### With the Delivery API
```javascript
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id_grab_it_from_contentful`,
accessToken: `your_token_id_grab_it_from_contentful`
},
},
]
```

### With the Preview API
```javascript
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: `your_space_id_grab_it_from_contentful`,
accessToken: `your_token_id_grab_it_from_contentful`,
host: `preview.contentful.com`
},
},
]
```

0 comments on commit 8e27d72

Please sign in to comment.