-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from northhighland/add
move
- Loading branch information
Showing
76 changed files
with
29,020 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 1 | ||
|
||
update_configs: | ||
- package_manager: javascript | ||
directory: / | ||
update_schedule: live | ||
allowed_updates: | ||
- match: | ||
update_type: security | ||
automerged_updates: | ||
- match: | ||
dependency_type: all | ||
update_type: in_range | ||
version_requirement_updates: widen_ranges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 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/ | ||
static/admin/*.bundle.* | ||
.DS_Store | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. --> | ||
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> | ||
<!-- Try to link to an open issue for more information. --> | ||
|
||
|
||
<!-- In addition to that please answer these questions: --> | ||
|
||
**What kind of change does this PR introduce?** | ||
|
||
<!-- E.g. a bugfix, feature, refactoring, build related change, etc… --> | ||
|
||
**Does this PR introduce a breaking change?** | ||
|
||
<!-- If this PR introduces a breaking change, please describe the impact and a migration path for existing applications. --> | ||
|
||
**What needs to be documented once your changes are merged?** | ||
|
||
<!-- List all the information that needs to be added to the documentation after merge --> | ||
<!-- When your changes are merged you will be asked to contribute this to the documentation --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Gatsby + Netlify CMS Starter | ||
|
||
[](https://app.netlify.com/sites/gatsby-starter-netlify-cms-ci/deploys) | ||
|
||
**Note:** This starter uses [Gatsby v2](https://www.gatsbyjs.org/blog/2018-09-17-gatsby-v2/). | ||
|
||
This repo contains an example business website that is built with [Gatsby](https://www.gatsbyjs.org/), and [Netlify CMS](https://www.netlifycms.org): **[Demo Link](https://hungry-saha-c402bb.netlify.app/)**. | ||
|
||
It follows the [JAMstack architecture](https://jamstack.org) by using Git as a single source of truth, and [Netlify](https://www.netlify.com) for continuous deployment, and CDN distribution. | ||
|
||
## Features | ||
|
||
- A simple landing page with blog functionality built with Netlify CMS | ||
- Editabe Pages: Landing, About, Product, Blog-Collection and Contact page with Netlify Form support | ||
- Create Blog posts from Netlify CMS | ||
- Tags: Separate page for posts under each tag | ||
- Basic directory organization | ||
- Uses Bulma for styling, but size is reduced by `purge-css-plugin` | ||
- Blazing fast loading times thanks to pre-rendered HTML and automatic chunk loading of JS files | ||
- Uses `gatsby-image` with Netlify-CMS preview support | ||
- Separate components for everything | ||
- Netlify deploy configuration | ||
- Netlify function support, see `lambda` folder | ||
- Perfect score on Lighthouse for SEO, Accessibility and Performance (wip:PWA) | ||
- ..and more | ||
|
||
## Prerequisites | ||
|
||
- Node (I recommend using v8.2.0 or higher) | ||
- [Gatsby CLI](https://www.gatsbyjs.org/docs/) | ||
- [Netlify CLI](https://github.com/netlify/cli) | ||
|
||
## Getting Started (Recommended) | ||
|
||
Netlify CMS can run in any frontend web environment, but the quickest way to try it out is by running it on a pre-configured starter site with Netlify. The example here is the Kaldi coffee company template (adapted from [One Click Hugo CMS](https://github.com/netlify-templates/one-click-hugo-cms)). Use the button below to build and deploy your own copy of the repository: | ||
|
||
<a href="https://app.netlify.com/start/deploy?repository=https://github.com/netlify-templates/gatsby-starter-netlify-cms&stack=cms"><img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify"></a> | ||
|
||
After clicking that button, you’ll authenticate with GitHub and choose a repository name. Netlify will then automatically create a repository in your GitHub account with a copy of the files from the template. Next, it will build and deploy the new site on Netlify, bringing you to the site dashboard when the build is complete. Next, you’ll need to set up Netlify’s Identity service to authorize users to log in to the CMS. | ||
|
||
### Access Locally | ||
|
||
Pulldown a local copy of the Github repository Netlify created for you, with the name you specified in the previous step | ||
|
||
```terminal | ||
git clone https://github.com/[GITHUB_USERNAME]/[REPO_NAME].git | ||
cd [REPO_NAME] | ||
yarn | ||
netlify dev # or ntl dev | ||
``` | ||
|
||
This uses the new [Netlify Dev](https://www.netlify.com/products/dev/?utm_source=blog&utm_medium=netlifycms&utm_campaign=devex) CLI feature to serve any functions you have in the `lambda` folder. | ||
|
||
To test the CMS locally, you'll need to run a production build of the site: | ||
|
||
```terminal | ||
npm run build | ||
netlify dev # or ntl dev | ||
``` | ||
|
||
### Media Libraries (installed, but optional) | ||
|
||
Media Libraries have been included in this starter as a default. If you are not planning to use `Uploadcare` or `Cloudinary` in your project, you **can** remove them from module import and registration in `src/cms/cms.js`. Here is an example of the lines to comment or remove them your project. | ||
|
||
```javascript | ||
import CMS from 'netlify-cms-app'; | ||
// import uploadcare from 'netlify-cms-media-library-uploadcare' | ||
// import cloudinary from 'netlify-cms-media-library-cloudinary' | ||
|
||
import IndexPagePreview from './preview-templates/IndexPagePreview'; | ||
|
||
// CMS.registerMediaLibrary(uploadcare); | ||
// CMS.registerMediaLibrary(cloudinary); | ||
|
||
CMS.registerPreviewTemplate('index', IndexPagePreview); | ||
``` | ||
|
||
Note: Don't forget to also remove them from `package.json` and `yarn.lock` / `package-lock.json` using `yarn` or `npm`. During the build netlify-cms-app will bundle the media libraries as well, having them removed will save you build time. | ||
Example: | ||
|
||
```terminal | ||
yarn remove netlify-cms-media-library-uploadcare | ||
``` | ||
|
||
OR | ||
|
||
```terminal | ||
yarn remove netlify-cms-media-library-cloudinary | ||
``` | ||
|
||
## Getting Started (Without Netlify) | ||
|
||
```terminal | ||
gatsby new [SITE_DIRECTORY_NAME] https://github.com/netlify-templates/gatsby-starter-netlify-cms/ | ||
cd [SITE_DIRECTORY_NAME] | ||
npm run build | ||
npm run serve | ||
``` | ||
|
||
### Setting up 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. | ||
|
||
```terminal | ||
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') | ||
|
||
MacOS users might also encounter some errors, for more info check [node-gyp](https://github.com/nodejs/node-gyp). We recommend using the latest stable node version. | ||
|
||
## Purgecss | ||
|
||
This plugin uses [gatsby-plugin-purgecss](https://www.gatsbyjs.org/packages/gatsby-plugin-purgecss/) and [bulma](https://bulma.io/). The bulma builds are usually ~170K but reduced 90% by purgecss. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/static/* | ||
Cache-Control: "public, max-age=360000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
module.exports = { | ||
siteMetadata: { | ||
title: 'Engineering at North Highland', | ||
description: | ||
'This repo contains an example business website that is built with Gatsby, and Netlify CMS.It follows the JAMstack architecture by using Git as a single source of truth, and Netlify for continuous deployment, and CDN distribution.', | ||
}, | ||
plugins: [ | ||
'gatsby-plugin-react-helmet', | ||
'gatsby-plugin-sass', | ||
{ | ||
// keep as first gatsby-source-filesystem plugin for gatsby image support | ||
resolve: 'gatsby-source-filesystem', | ||
options: { | ||
path: `${__dirname}/static/img`, | ||
name: 'uploads', | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-source-filesystem', | ||
options: { | ||
path: `${__dirname}/src/pages`, | ||
name: 'pages', | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-source-filesystem', | ||
options: { | ||
path: `${__dirname}/src/img`, | ||
name: 'images', | ||
}, | ||
}, | ||
'gatsby-plugin-sharp', | ||
'gatsby-transformer-sharp', | ||
{ | ||
resolve: 'gatsby-transformer-remark', | ||
options: { | ||
plugins: [ | ||
{ | ||
resolve: 'gatsby-remark-relative-images', | ||
options: { | ||
name: 'uploads', | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-remark-images', | ||
options: { | ||
// It's important to specify the maxWidth (in pixels) of | ||
// the content container as this plugin uses this as the | ||
// base for generating different widths of each image. | ||
maxWidth: 2048, | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-remark-copy-linked-files', | ||
options: { | ||
destinationDir: 'static', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-plugin-netlify-cms', | ||
options: { | ||
modulePath: `${__dirname}/src/cms/cms.js`, | ||
}, | ||
}, | ||
{ | ||
resolve: 'gatsby-plugin-purgecss', // purges all unused/unreferenced css rules | ||
options: { | ||
develop: true, // Activates purging in npm run develop | ||
purgeOnly: ['/all.sass'], // applies purging only on the bulma css file | ||
}, | ||
}, // must be after other CSS plugins | ||
'gatsby-plugin-netlify', // make sure to keep it last in the array | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const _ = require('lodash') | ||
const path = require('path') | ||
const { createFilePath } = require('gatsby-source-filesystem') | ||
const { fmImagesToRelative } = require('gatsby-remark-relative-images') | ||
|
||
exports.createPages = ({ actions, graphql }) => { | ||
const { createPage } = actions | ||
|
||
return graphql(` | ||
{ | ||
allMarkdownRemark(limit: 1000) { | ||
edges { | ||
node { | ||
id | ||
fields { | ||
slug | ||
} | ||
frontmatter { | ||
templateKey | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`).then((result) => { | ||
if (result.errors) { | ||
result.errors.forEach((e) => console.error(e.toString())) | ||
return Promise.reject(result.errors) | ||
} | ||
|
||
const posts = result.data.allMarkdownRemark.edges | ||
|
||
posts.forEach((edge) => { | ||
const id = edge.node.id | ||
createPage({ | ||
path: edge.node.fields.slug, | ||
component: path.resolve( | ||
`src/templates/${String(edge.node.frontmatter.templateKey)}.js` | ||
), | ||
// additional data can be passed via context | ||
context: { | ||
id, | ||
}, | ||
}) | ||
}) | ||
|
||
|
||
|
||
}) | ||
} | ||
|
||
exports.onCreateNode = ({ node, actions, getNode }) => { | ||
const { createNodeField } = actions | ||
fmImagesToRelative(node) // convert image paths for gatsby images | ||
|
||
if (node.internal.type === `MarkdownRemark`) { | ||
const value = createFilePath({ node, getNode }) | ||
createNodeField({ | ||
name: `slug`, | ||
node, | ||
value, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// For more info, check https://www.netlify.com/docs/functions/#javascript-lambda-functions | ||
module.exports.handler = async function(event, context) { | ||
console.log("queryStringParameters", event.queryStringParameters) | ||
return { | ||
// return null to show no errors | ||
statusCode: 200, // http status code | ||
body: JSON.stringify({ | ||
msg: "Hello, World! This is better " + Math.round(Math.random() * 10) | ||
}) | ||
} | ||
} | ||
|
||
// Now you are ready to access this API from anywhere in your Gatsby app! For example, in any event handler or lifecycle method, insert: | ||
// fetch("/.netlify/functions/hello") | ||
// .then(response => response.json()) | ||
// .then(console.log) | ||
// For more info see: https://www.gatsbyjs.org/blog/2018-12-17-turning-the-static-dynamic/#static-dynamic-is-a-spectrum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[build] | ||
publish = "public" | ||
command = "npm run build" | ||
functions = "lambda" | ||
[build.environment] | ||
NODE_VERSION = "12" | ||
YARN_VERSION = "1.22.4" | ||
YARN_FLAGS = "--no-ignore-optional" |
Oops, something went wrong.