├── .gitignore ├── LICENSE ├── README.md ├── blog └── my-first-blog.md ├── gatsby-config.js ├── gatsby-node.js ├── package-lock.json ├── package.json ├── renovate.json ├── src ├── pages │ └── index.js └── templates │ └── blogTemplate.js ├── static └── admin │ └── config.yml └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | .cache/ 61 | public 62 | yarn-error.log 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gatsby-netlify-cms-example 2 | Starter with the bare essentials needed for a [Gatsby](https://www.gatsbyjs.org/) site with [Netlify 3 | CMS](https://netlifycms.org). 4 | 5 | Install this starter (assuming Gatsby is installed) by running from your CLI: 6 | ``` 7 | gatsby new gatsby-site https://github.com/erquhart/gatsby-netlify-cms-example 8 | ``` 9 | 10 | ## Running in development 11 | `gatsby develop` 12 | -------------------------------------------------------------------------------- /blog/my-first-blog.md: -------------------------------------------------------------------------------- 1 | --- 2 | path: /blog/my-first-blog 3 | date: 2018-01-11T00:00:00-05:00 4 | title: My First Blog 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | `gatsby-plugin-netlify-cms`, 4 | { 5 | resolve: `gatsby-source-filesystem`, 6 | options: { 7 | path: `${__dirname}/blog`, 8 | name: 'markdown-pages', 9 | }, 10 | }, 11 | `gatsby-transformer-remark`, 12 | ], 13 | } 14 | -------------------------------------------------------------------------------- /gatsby-node.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | exports.createPages = ({ boundActionCreators, graphql }) => { 4 | const { createPage } = boundActionCreators; 5 | 6 | const blogPostTemplate = path.resolve('src/templates/blogTemplate.js'); 7 | 8 | return graphql(` 9 | { 10 | allMarkdownRemark( 11 | sort: { order: DESC, fields: [frontmatter___date] } 12 | limit: 1000 13 | ) { 14 | edges { 15 | node { 16 | excerpt(pruneLength: 250) 17 | html 18 | id 19 | frontmatter { 20 | date 21 | path 22 | title 23 | } 24 | } 25 | } 26 | } 27 | } 28 | `).then(result => { 29 | if (result.errors) { 30 | return Promise.reject(result.errors); 31 | } 32 | 33 | result.data.allMarkdownRemark.edges.forEach(({ node }) => { 34 | createPage({ 35 | path: node.frontmatter.path, 36 | component: blogPostTemplate, 37 | context: {}, 38 | }); 39 | }); 40 | }); 41 | }; 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatsby-starter-hello-world", 3 | "description": "Gatsby hello world starter", 4 | "license": "MIT", 5 | "scripts": { 6 | "develop": "gatsby develop", 7 | "build": "gatsby build", 8 | "serve": "gatsby serve" 9 | }, 10 | "dependencies": { 11 | "gatsby": "^1.9.153", 12 | "gatsby-link": "^1.6.34", 13 | "gatsby-plugin-netlify-cms": "^1.0.0", 14 | "gatsby-source-filesystem": "^1.5.11", 15 | "gatsby-transformer-remark": "^1.7.28" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": [ 4 | "config:base" 5 | ], 6 | "rangeStrategy": "replace", 7 | "lockFileMaintenance": { 8 | "enabled": true, 9 | "extends": "schedule:weekly" 10 | }, 11 | "prHourlyLimit": 0 12 | } 13 | -------------------------------------------------------------------------------- /src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | 3 | export default () =>
Hello world!
4 | -------------------------------------------------------------------------------- /src/templates/blogTemplate.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default function Template({ 4 | data, 5 | }) { 6 | const { markdownRemark } = data; 7 | const { frontmatter, html } = markdownRemark; 8 | return ( 9 |
10 |
11 |

{frontmatter.title}

12 |

{frontmatter.date}

13 |
17 |
18 |
19 | ); 20 | } 21 | 22 | export const pageQuery = graphql` 23 | query BlogPostByPath($path: String!) { 24 | markdownRemark(frontmatter: { path: { eq: $path } }) { 25 | html 26 | frontmatter { 27 | date(formatString: "MMMM DD, YYYY") 28 | path 29 | title 30 | } 31 | } 32 | } 33 | `; 34 | -------------------------------------------------------------------------------- /static/admin/config.yml: -------------------------------------------------------------------------------- 1 | backend: 2 | name: github 3 | repo: erquhart/gatsby-netlify-cms-example #replace with your username/repo 4 | 5 | media_folder: static/assets 6 | 7 | collections: 8 | - name: blog 9 | label: Blog 10 | folder: blog 11 | create: true 12 | fields: 13 | - { name: path, label: Path } 14 | - { name: date, label: Date, widget: date } 15 | - { name: title, label: Title } 16 | - { name: body, label: Body, widget: markdown } 17 | --------------------------------------------------------------------------------