Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwiemer committed Feb 23, 2018
0 parents commit 1c9ae0b
Show file tree
Hide file tree
Showing 27 changed files with 2,460 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .contentful.json.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"development": {
"host": "preview.contentful.com",
"spaceId": "...",
"accessToken": "..."
},
"production": {
"spaceId": "...",
"accessToken": "..."
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.cache/
public/
.DS_Store
yarn-error.log
.env*
npm-debug.log
package-lock.json
.contentful.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Ryan Wiemer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# gatsby-starter-gcn
A starter template to build amazing static websites with Gatsby, Contentful and Netlify. Heavily inspired by the [gatsby-contentful-starter](https://github.com/contentful-userland/gatsby-contentful-starter).

## Features
* Contentful integration with ready to go placeholder content
* Netlify integration including a pre-built contact form ✌️
* Minimal responsive design - made to customize or tear apart
* SEO friendly

## Getting Started

### Clone and Install
```
git clone [email protected]:ryanwiemer/gatsby-starter-gcn.git
npm i
```

### Setup
`npm run setup`

Enter in the requested info for your designated space found here:

**app.contentful.com** -> **Space Settings** -> **API keys**

[More detailed setup](https://github.com/contentful-userland/gatsby-contentful-starter/blob/master/README.md#set-up-of-the-needed-content-model-and-create-a-configuration-file)

## Customization

### Website Data
Edit `/src/utils/siteConfig.js`
```
module.exports = {
siteTitle: 'GCN',
siteDescription: 'A starter template to build amazing static websites with Gatsby, Contentful and Netlify',
siteUrl: 'https://gcn.netlify.com',
pathPrefix: '/'
};
```

### Styled Components Theme & Colors
Edit `/src/styles/theme.js`
```
const theme = {
colors: {
base: '#121212',
secondary: '#f1f1f1',
highlight: '#5b8bf7'
},
sizes: {
maxWidth: '1200px'
},
responsive: {
small: '35em',
medium: '50em',
large: '70em'
}
};
```

### Todo
- [] Add specific steps for Netlify deployment to the README
- [] Add tips, tricks, and caveats to the README
- [] Add better placeholder content
- [] Add tags / tag pages
- [] Come up with a solution for a preview / staging environment
- [] Navigation generated by Contentful?
91 changes: 91 additions & 0 deletions bin/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const spaceImport = require('contentful-import')
const exportFile = require('../contentful/export.json')
const inquirer = require('inquirer')
const chalk = require('chalk')
const path = require('path')
const { writeFileSync } = require('fs')

console.log(`
To set up this project you need to provide your Space ID
and the belonging API access tokens.
You can find all the needed information in your Contentful space under:
${chalk.yellow(
`app.contentful.com ${chalk.red('->')} Space Settings ${chalk.red(
'->'
)} API keys`
)}
The ${chalk.green('Content Management API Token')}
will be used to import and write data to your space.
The ${chalk.green('Content Delivery API Token')}
will be used to ship published production-ready content in your Gatsby app.
The ${chalk.green('Content Preview API Token')}
will be used to show not published data in your development environment.
Ready? Let's do it! 🎉
`)

const questions = [
{
name: 'spaceId',
message: 'Your Space ID',
validate: input =>
/^[a-z0-9]{12}$/.test(input) ||
'Space ID must be 12 lowercase characters',
},
{
name: 'managementToken',
message: 'Your Content Management API access token',
},
{
name: 'accessToken',
message: 'Your Content Delivery API access token',
},
{
name: 'previewToken',
message: 'Your Content Preview API access token',
},
]

inquirer
.prompt(questions)
.then(({ spaceId, managementToken, accessToken, previewToken }) => {
console.log('Writing config file...')
const configFilePath = path.resolve(__dirname, '..', '.contentful.json')
writeFileSync(
configFilePath,
JSON.stringify(
{
development: {
host: 'preview.contentful.com',
spaceId,
accessToken: previewToken,
},
production: {
spaceId,
accessToken,
},
},
null,
2
)
)
console.log(`Config file ${chalk.yellow(configFilePath)} written`)

return { spaceId, managementToken }
})
.then(({ spaceId, managementToken }) =>
spaceImport({ spaceId, managementToken, content: exportFile })
)
.then((_, error) => {
console.log(
`All set! You can now run ${chalk.yellow(
'npm run dev'
)} to see it in action.`
)
})
.catch(error => console.error(error))
Loading

0 comments on commit 1c9ae0b

Please sign in to comment.