mirror of
https://github.com/kingomarnajjar/gatsby-starter-netlify-cms.git
synced 2026-07-25 22:27:24 +10:00
first commit
This commit is contained in:
commit
fd86fe312a
16 changed files with 20200 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -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
|
||||
22
LICENSE
Normal file
22
LICENSE
Normal file
|
|
@ -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.
|
||||
|
||||
13
README.md
Normal file
13
README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# gatsby-starter-default
|
||||
The default Gatsby starter
|
||||
|
||||
For an overview of the project structure please refer to the [Gatsby documentation - Building with Components](https://www.gatsbyjs.org/docs/building-with-components/)
|
||||
|
||||
Install this starter (assuming Gatsby is installed) by running from your CLI:
|
||||
```
|
||||
gatsby new gatsby-example-site
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
[](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default)
|
||||
23
gatsby-config.js
Normal file
23
gatsby-config.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
siteMetadata: {
|
||||
title: `Gatsby Default Starter`
|
||||
},
|
||||
plugins: [
|
||||
'gatsby-plugin-react-helmet',
|
||||
`gatsby-plugin-styled-components`,
|
||||
`gatsby-plugin-sass`,
|
||||
{
|
||||
resolve: `gatsby-source-filesystem`,
|
||||
options: {
|
||||
path: `${__dirname}/src/pages`,
|
||||
name: 'pages'
|
||||
}
|
||||
},
|
||||
{
|
||||
resolve: 'gatsby-transformer-remark',
|
||||
options: {
|
||||
plugins: []
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
37
gatsby-node.js
Normal file
37
gatsby-node.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const path = require('path');
|
||||
|
||||
exports.createPages = ({ boundActionCreators, graphql }) => {
|
||||
const { createPage } = boundActionCreators;
|
||||
|
||||
const blogPostTemplate = path.resolve(`src/templates/blog-post.js`);
|
||||
|
||||
return graphql(`
|
||||
{
|
||||
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }, limit: 1000) {
|
||||
edges {
|
||||
node {
|
||||
excerpt(pruneLength: 400)
|
||||
html
|
||||
id
|
||||
frontmatter {
|
||||
path
|
||||
date
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`).then(result => {
|
||||
if (result.errors) {
|
||||
return Promise.reject(result.errors);
|
||||
}
|
||||
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
|
||||
createPage({
|
||||
path: node.frontmatter.path,
|
||||
component: blogPostTemplate,
|
||||
context: {} // additional data can be passed via context
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
11335
package-lock.json
generated
Normal file
11335
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
30
package.json
Normal file
30
package.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "gatsby-starter-default",
|
||||
"description": "Gatsby default starter",
|
||||
"version": "1.0.0",
|
||||
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
||||
"dependencies": {
|
||||
"bulma": "^0.6.0",
|
||||
"gatsby": "^1.9.63",
|
||||
"gatsby-link": "^1.6.21",
|
||||
"gatsby-plugin-react-helmet": "^1.0.5",
|
||||
"gatsby-plugin-sass": "^1.0.12",
|
||||
"gatsby-plugin-styled-components": "^1.0.5",
|
||||
"gatsby-source-filesystem": "^1.5.5",
|
||||
"gatsby-transformer-remark": "^1.7.17"
|
||||
},
|
||||
"keywords": [
|
||||
"gatsby"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "n/a",
|
||||
"scripts": {
|
||||
"build": "gatsby build",
|
||||
"develop": "gatsby develop",
|
||||
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^1.7.4"
|
||||
}
|
||||
}
|
||||
5
src/img/github-icon.svg
Normal file
5
src/img/github-icon.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="438.549px" height="438.549px" viewBox="0 0 438.549 438.549" style="enable-background:new 0 0 438.549 438.549;" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M409.132,114.573c-19.608-33.596-46.205-60.194-79.798-79.8C295.736,15.166,259.057,5.365,219.271,5.365 c-39.781,0-76.472,9.804-110.063,29.408c-33.596,19.605-60.192,46.204-79.8,79.8C9.803,148.168,0,184.854,0,224.63 c0,47.78,13.94,90.745,41.827,128.906c27.884,38.164,63.906,64.572,108.063,79.227c5.14,0.954,8.945,0.283,11.419-1.996 c2.475-2.282,3.711-5.14,3.711-8.562c0-0.571-0.049-5.708-0.144-15.417c-0.098-9.709-0.144-18.179-0.144-25.406l-6.567,1.136 c-4.187,0.767-9.469,1.092-15.846,1c-6.374-0.089-12.991-0.757-19.842-1.999c-6.854-1.231-13.229-4.086-19.13-8.559 c-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559 c-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-0.951-2.568-2.098-3.711-3.429c-1.142-1.331-1.997-2.663-2.568-3.997 c-0.572-1.335-0.098-2.43,1.427-3.289c1.525-0.859,4.281-1.276,8.28-1.276l5.708,0.853c3.807,0.763,8.516,3.042,14.133,6.851 c5.614,3.806,10.229,8.754,13.846,14.842c4.38,7.806,9.657,13.754,15.846,17.847c6.184,4.093,12.419,6.136,18.699,6.136 c6.28,0,11.704-0.476,16.274-1.423c4.565-0.952,8.848-2.383,12.847-4.285c1.713-12.758,6.377-22.559,13.988-29.41 c-10.848-1.14-20.601-2.857-29.264-5.14c-8.658-2.286-17.605-5.996-26.835-11.14c-9.235-5.137-16.896-11.516-22.985-19.126 c-6.09-7.614-11.088-17.61-14.987-29.979c-3.901-12.374-5.852-26.648-5.852-42.826c0-23.035,7.52-42.637,22.557-58.817 c-7.044-17.318-6.379-36.732,1.997-58.24c5.52-1.715,13.706-0.428,24.554,3.853c10.85,4.283,18.794,7.952,23.84,10.994 c5.046,3.041,9.089,5.618,12.135,7.708c17.705-4.947,35.976-7.421,54.818-7.421s37.117,2.474,54.823,7.421l10.849-6.849 c7.419-4.57,16.18-8.758,26.262-12.565c10.088-3.805,17.802-4.853,23.134-3.138c8.562,21.509,9.325,40.922,2.279,58.24 c15.036,16.18,22.559,35.787,22.559,58.817c0,16.178-1.958,30.497-5.853,42.966c-3.9,12.471-8.941,22.457-15.125,29.979 c-6.191,7.521-13.901,13.85-23.131,18.986c-9.232,5.14-18.182,8.85-26.84,11.136c-8.662,2.286-18.415,4.004-29.263,5.146 c9.894,8.562,14.842,22.077,14.842,40.539v60.237c0,3.422,1.19,6.279,3.572,8.562c2.379,2.279,6.136,2.95,11.276,1.995 c44.163-14.653,80.185-41.062,108.068-79.226c27.88-38.161,41.825-81.126,41.825-128.906 C438.536,184.851,428.728,148.168,409.132,114.573z"/>
|
||||
</g>
|
||||
<div xmlns="" id="divScriptsUsed" style="display: none"/><script xmlns="" id="globalVarsDetection" src="chrome-extension://cmkdbmfndkfgebldhnkbfhlneefdaaip/js/wrs_env.js"/></svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
35
src/layouts/index.js
Normal file
35
src/layouts/index.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Link from 'gatsby-link';
|
||||
import Helmet from 'react-helmet';
|
||||
import github from '../img/github-icon.svg';
|
||||
import 'bulma';
|
||||
|
||||
const Navbar = () => (
|
||||
<nav className="navbar is-light">
|
||||
<div className="navbar-brand">
|
||||
<Link to="/" className="navbar-item">
|
||||
Gatsby powered by Netlify CMS
|
||||
</Link>
|
||||
<a className="navbar-item" href="https://github.com/AustinGreen/gatsby-netlify-cms-boilerplate" target="_blank">
|
||||
<span className="icon">
|
||||
<img src={github} alt="Github" />
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
|
||||
const TemplateWrapper = ({ children }) => (
|
||||
<div>
|
||||
<Helmet title="Home | Gatsby + Netlify CMS" />
|
||||
<Navbar />
|
||||
<div>{children()}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
TemplateWrapper.propTypes = {
|
||||
children: PropTypes.func
|
||||
};
|
||||
|
||||
export default TemplateWrapper;
|
||||
10
src/pages/404.js
Normal file
10
src/pages/404.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import React from 'react'
|
||||
|
||||
const NotFoundPage = () => (
|
||||
<div>
|
||||
<h1>NOT FOUND</h1>
|
||||
<p>You just hit a route that doesn't exist... the sadness.</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
export default NotFoundPage
|
||||
20
src/pages/blog/2017-08-04-introduction-to-graphql.md
Normal file
20
src/pages/blog/2017-08-04-introduction-to-graphql.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
layout: blog
|
||||
path: /intro-to-graphql
|
||||
date: '2017-08-08T17:12:33.962Z'
|
||||
title: Introduction to GraphQL
|
||||
---
|
||||
Modern apps are interdependent and dynamic. For example, you probably sign in to various web apps using your GitHub account. These apps may be grabbing your avatar directly from GitHub, or some information about your projects. The data about your project is always changing so, as an added bonus, these connections are constantly updating the information that is displayed.
|
||||
|
||||
GitHub isn’t the only web app that does this. A few examples of **rich data** sources are:
|
||||
|
||||
- Weather Underground: get access to your local weather or report it from you home weather station
|
||||
- Flight stats: grab information about any flight, and
|
||||
- ESPN: keep track of your favorite sports team’s record
|
||||
- This data is available to you because the developers of these apps created a public Application Program Interface (API).
|
||||
|
||||
This course is going to introduce the concept of using APIs via GitHub’s GraphQL. You’ll learn how to gather data from GitHub, and how to make a simple change.
|
||||
|
||||
### More Examples
|
||||
|
||||
- Here's another
|
||||
50
src/pages/index.js
Normal file
50
src/pages/index.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import React from 'react';
|
||||
import Link from 'gatsby-link';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
export default function Index({ data }) {
|
||||
const { edges: posts } = data.allMarkdownRemark;
|
||||
return (
|
||||
<section className="section">
|
||||
<div className="container">
|
||||
{posts.filter(post => post.node.frontmatter.title.length > 0).map(({ node: post }) => {
|
||||
return (
|
||||
<div className="content" style={{ border: '1px solid #eaecee', padding: '2em 4em' }} key={post.id}>
|
||||
<p>
|
||||
<Link to={post.frontmatter.path}>{post.frontmatter.title}</Link>
|
||||
<span> • </span>
|
||||
<small>{post.frontmatter.date}</small>
|
||||
</p>
|
||||
<p>
|
||||
{post.excerpt}
|
||||
<br />
|
||||
<br />
|
||||
<Link className="button is-info is-small" to={post.frontmatter.path}>
|
||||
Keep Reading
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export const pageQuery = graphql`
|
||||
query IndexQuery {
|
||||
allMarkdownRemark(sort: { order: DESC, fields: [frontmatter___date] }) {
|
||||
edges {
|
||||
node {
|
||||
excerpt(pruneLength: 400)
|
||||
id
|
||||
frontmatter {
|
||||
title
|
||||
date(formatString: "MMMM DD, YYYY")
|
||||
path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
28
src/templates/blog-post.js
Normal file
28
src/templates/blog-post.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
export default function Template({ data }) {
|
||||
const { markdownRemark: post } = data;
|
||||
return (
|
||||
<section className="section">
|
||||
<Helmet title={`Blog | ${post.frontmatter.title}`} />
|
||||
<div className="container content">
|
||||
<h1 className="title is-size-2 has-text-info is-bold-light">{post.frontmatter.title}</h1>
|
||||
<div dangerouslySetInnerHTML={{ __html: post.html }} />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export const pageQuery = graphql`
|
||||
query BlogPostByPath($path: String!) {
|
||||
markdownRemark(frontmatter: { path: { eq: $path } }) {
|
||||
html
|
||||
frontmatter {
|
||||
path
|
||||
date(formatString: "MMMM DD, YYYY")
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
18
static/admin/config.yml
Normal file
18
static/admin/config.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
backend:
|
||||
name: github
|
||||
repo: AustinGreen/gatsby-netlify-cms-boilerplate # Path to your Github repository
|
||||
branch: master # Branch to update
|
||||
|
||||
media_folder: "/static"
|
||||
|
||||
collections:
|
||||
- name: "blog" # Used in routes, e.g., /admin/collections/blog
|
||||
label: "Blog" # Used in the UI
|
||||
folder: "src/pages/blog" # The path to the folder where the documents are stored
|
||||
create: true # Allow users to create new documents in this collection
|
||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
|
||||
fields: # The fields for each document, usually in front matter
|
||||
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
|
||||
- {label: "Path", name: "path", widget: "string"}
|
||||
- {label: "Title", name: "title", widget: "string"}
|
||||
- {label: "Body", name: "body", widget: "markdown"}
|
||||
14
static/admin/index.html
Normal file
14
static/admin/index.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Content Manager</title>
|
||||
|
||||
<link rel="stylesheet" href="https://unpkg.com/netlify-cms@~0.4/dist/cms.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://unpkg.com/netlify-cms@~0.4/dist/cms.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue