Skip to content

Commit 6f9bfea

Browse files
committed
Initializing repo
0 parents  commit 6f9bfea

40 files changed

+30279
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Project dependencies
2+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
3+
node_modules
4+
.cache/
5+
# Build directory
6+
public/
7+
.DS_Store
8+
yarn-error.log

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"trailingComma": "es5",
3+
"semi": false,
4+
"overrides": [
5+
{
6+
"files": ".{prettier,babel}rc",
7+
"options": { "parser": "json" }
8+
}
9+
]
10+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Gatsby + Netlify CMS Starter
2+
3+
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/.
4+
5+
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.
6+
7+
## Getting Started
8+
9+
### Prerequisites
10+
11+
- Node (I recommend using v8.2.0 or higher)
12+
- [Gatsby CLI](https://www.gatsbyjs.org/docs/)
13+
14+
### Run Locally
15+
```
16+
gatsby new [SITE_DIRECTORY_NAME] https://github.com/AustinGreen/gatsby-starter-netlify-cms/
17+
$ cd [SITE_DIRECTORY_NAME]
18+
$ gatsby build
19+
$ gatsby serve
20+
```
21+
22+
## Accessing the CMS
23+
Follow the [Netlify CMS Quick Start Guide](https://www.netlifycms.org/docs/quick-start/#authentication) to set up authentication, and hosting.
24+
25+
26+
- - -
27+
28+
### Debugging
29+
Windows users might encounter ```node-gyp``` errors when trying to npm install.
30+
To resolve, make sure that you have both Python 2.7 and the Visual C++ build environment installed.
31+
```
32+
npm config set python python2.7
33+
npm install --global --production windows-build-tools
34+
```
35+
36+
[Full details here](https://www.npmjs.com/package/node-gyp 'NPM node-gyp page')

gatsby-config.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module.exports = {
2+
siteMetadata: {
3+
title: "Gatsby Default Starter",
4+
description: "",
5+
siteUrl: "https://adamyonk.com",
6+
author: "Adam Jahnke",
7+
},
8+
plugins: [
9+
{ resolve: "gatsby-plugin-react-next" },
10+
{ resolve: "gatsby-plugin-react-helmet" },
11+
{ resolve: "gatsby-plugin-styled-jsx" },
12+
// {
13+
// resolve: "gatsby-plugin-feed-generator",
14+
// feedQuery: `
15+
// {
16+
// allMarkdownRemark(
17+
// filter: { frontmatter: { templateKey: { eq: "post" } } }
18+
// sort: { order: DESC, fields: [frontmatter___date] }
19+
// ) {
20+
// edges {
21+
// node {
22+
// html
23+
// id
24+
// frontmatter {
25+
// date
26+
// path
27+
// title
28+
// }
29+
// }
30+
// }
31+
// }
32+
// }
33+
// `,
34+
// },
35+
{
36+
resolve: "gatsby-source-filesystem",
37+
options: {
38+
path: `${__dirname}/src/pages`,
39+
name: "pages",
40+
},
41+
},
42+
{
43+
resolve: "gatsby-transformer-remark",
44+
options: {
45+
plugins: [
46+
{
47+
resolve: "gatsby-remark-images",
48+
options: {
49+
maxWidth: 800,
50+
linkImagesToOriginal: true,
51+
},
52+
},
53+
],
54+
},
55+
},
56+
],
57+
}

gatsby-node.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const path = require("path")
2+
3+
exports.createPages = ({ boundActionCreators, graphql }) => {
4+
const { createPage } = boundActionCreators
5+
6+
return graphql(`
7+
{
8+
pages: allMarkdownRemark(
9+
sort: { order: DESC, fields: [frontmatter___date] }
10+
limit: 1000
11+
) {
12+
edges {
13+
node {
14+
excerpt(pruneLength: 400)
15+
html
16+
id
17+
frontmatter {
18+
templateKey
19+
path
20+
date
21+
title
22+
}
23+
}
24+
}
25+
}
26+
posts: allMarkdownRemark(
27+
filter: { frontmatter: { templateKey: { eq: "post" } } }
28+
limit: 1000
29+
) {
30+
edges {
31+
node {
32+
frontmatter {
33+
tags
34+
}
35+
}
36+
}
37+
}
38+
}
39+
`).then(result => {
40+
if (result.errors) {
41+
return Promise.reject(result.errors)
42+
}
43+
result.data.posts.edges
44+
.reduce((a, { node: { frontmatter: { tags } } }) => {
45+
for (const tag of tags) {
46+
a.add(tag)
47+
}
48+
return a
49+
}, new Set())
50+
.forEach(tag => {
51+
createPage({
52+
path: `/tags/${tag}`,
53+
component: path.resolve(`src/templates/tag.js`),
54+
context: { tag }, // additional data can be passed via context
55+
})
56+
})
57+
result.data.pages.edges.forEach(({ node }) => {
58+
createPage({
59+
path: node.frontmatter.path,
60+
component: path.resolve(
61+
`src/templates/${String(node.frontmatter.templateKey)}.js`
62+
),
63+
context: {}, // additional data can be passed via context
64+
})
65+
})
66+
})
67+
}

0 commit comments

Comments
 (0)