Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initializing repo
  • Loading branch information
adamyonk committed Mar 30, 2018
0 parents commit 6f9bfea
Show file tree
Hide file tree
Showing 40 changed files with 30,279 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
# Project dependencies
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
.cache/
# Build directory
public/
.DS_Store
yarn-error.log
10 changes: 10 additions & 0 deletions .prettierrc
@@ -0,0 +1,10 @@
{
"trailingComma": "es5",
"semi": false,
"overrides": [
{
"files": ".{prettier,babel}rc",
"options": { "parser": "json" }
}
]
}
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 gatsbyjs

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.

36 changes: 36 additions & 0 deletions README.md
@@ -0,0 +1,36 @@
# Gatsby + Netlify CMS Starter

This repo contains an example blog that is built with [Gatsby](https://www.gatsbyjs.org/), and [Netlify CMS](netlifycms.org): https://gatsby-netlify-cms.netlify.com/.

It follows the [JAMstack architecture](https://jamstack.org) by using Git as a single source of truth, and [Netlify](netlify.com) for continuous deployment, and CDN distribution.

## Getting Started

### Prerequisites

- Node (I recommend using v8.2.0 or higher)
- [Gatsby CLI](https://www.gatsbyjs.org/docs/)

### Run Locally
```
gatsby new [SITE_DIRECTORY_NAME] https://github.com/AustinGreen/gatsby-starter-netlify-cms/
$ cd [SITE_DIRECTORY_NAME]
$ gatsby build
$ gatsby serve
```

## Accessing the CMS
Follow the [Netlify CMS Quick Start Guide](https://www.netlifycms.org/docs/quick-start/#authentication) to set up authentication, and hosting.


- - -

### Debugging
Windows users might encounter ```node-gyp``` errors when trying to npm install.
To resolve, make sure that you have both Python 2.7 and the Visual C++ build environment installed.
```
npm config set python python2.7
npm install --global --production windows-build-tools
```

[Full details here](https://www.npmjs.com/package/node-gyp 'NPM node-gyp page')
57 changes: 57 additions & 0 deletions gatsby-config.js
@@ -0,0 +1,57 @@
module.exports = {
siteMetadata: {
title: "Gatsby Default Starter",
description: "",
siteUrl: "https://adamyonk.com",
author: "Adam Jahnke",
},
plugins: [
{ resolve: "gatsby-plugin-react-next" },
{ resolve: "gatsby-plugin-react-helmet" },
{ resolve: "gatsby-plugin-styled-jsx" },
// {
// resolve: "gatsby-plugin-feed-generator",
// feedQuery: `
// {
// allMarkdownRemark(
// filter: { frontmatter: { templateKey: { eq: "post" } } }
// sort: { order: DESC, fields: [frontmatter___date] }
// ) {
// edges {
// node {
// html
// id
// frontmatter {
// date
// path
// title
// }
// }
// }
// }
// }
// `,
// },
{
resolve: "gatsby-source-filesystem",
options: {
path: `${__dirname}/src/pages`,
name: "pages",
},
},
{
resolve: "gatsby-transformer-remark",
options: {
plugins: [
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 800,
linkImagesToOriginal: true,
},
},
],
},
},
],
}
67 changes: 67 additions & 0 deletions gatsby-node.js
@@ -0,0 +1,67 @@
const path = require("path")

exports.createPages = ({ boundActionCreators, graphql }) => {
const { createPage } = boundActionCreators

return graphql(`
{
pages: allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
limit: 1000
) {
edges {
node {
excerpt(pruneLength: 400)
html
id
frontmatter {
templateKey
path
date
title
}
}
}
}
posts: allMarkdownRemark(
filter: { frontmatter: { templateKey: { eq: "post" } } }
limit: 1000
) {
edges {
node {
frontmatter {
tags
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors)
}
result.data.posts.edges
.reduce((a, { node: { frontmatter: { tags } } }) => {
for (const tag of tags) {
a.add(tag)
}
return a
}, new Set())
.forEach(tag => {
createPage({
path: `/tags/${tag}`,
component: path.resolve(`src/templates/tag.js`),
context: { tag }, // additional data can be passed via context
})
})
result.data.pages.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: path.resolve(
`src/templates/${String(node.frontmatter.templateKey)}.js`
),
context: {}, // additional data can be passed via context
})
})
})
}

0 comments on commit 6f9bfea

Please sign in to comment.