Skip to content

Commit

Permalink
- Add eslintrc
Browse files Browse the repository at this point in the history
- add editorconfig
- update .gitignore
- add .nvmrc to make sure folks and CI tools (like netlify) are on consistent versions of node
- add prettierignore and prettierrc for code style
- add config.js for basic central config
- npm install esm so we can make use of es6 imports in node
- add scripts to package.json. Note, to use es6 imports we need these scripts instead of `gatsby develop`
- import the fragment into createPosts
- moved Post template into a directory with an index.js and a data.js file. The data.js defines the graphql fragment for the template.
  • Loading branch information
jasonbahl committed Mar 5, 2019
1 parent 852aa27 commit 3074c22
Show file tree
Hide file tree
Showing 14 changed files with 14,106 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
public
.cache
.cache
.idea
10 changes: 10 additions & 0 deletions packages/twentynineteen-gatsby-theme/.editoconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
76 changes: 76 additions & 0 deletions packages/twentynineteen-gatsby-theme/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"parser": "babel-eslint",
"extends": [
"google",
"eslint:recommended",
"plugin:flowtype/recommended",
"plugin:react/recommended",
"prettier",
"prettier/flowtype",
"prettier/react"
],
"plugins": ["flowtype", "prettier", "react"],
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"globals": {
"before": true,
"spyOn": true,
"__PATH_PREFIX__": true
},
"rules": {
"arrow-body-style": [
"error",
"as-needed",
{ "requireReturnForObjectLiteral": true }
],
"consistent-return": ["error"],
"no-console": "off",
"no-inner-declarations": "off",
"prettier/prettier": "error",
"quotes": ["error", "backtick"],
"react/display-name": "off",
"react/jsx-key": "warn",
"react/no-unescaped-entities": "warn",
"react/prop-types": "off",
"require-jsdoc": "off",
"valid-jsdoc": "off"
},
"overrides": [
{
"files": [
"packages/**/gatsby-browser.js",
"packages/gatsby/cache-dir/**/*"
],
"env": {
"browser": true
},
"globals": {
"___loader": false,
"___emitter": false
}
},
{
"files": ["**/cypress/integration/**/*", "**/cypress/support/**/*"],
"globals": {
"cy": false,
"Cypress": false
}
}
],
"settings": {
"react": {
"version": "16.4.2"
}
}
}
71 changes: 70 additions & 1 deletion packages/twentynineteen-gatsby-theme/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
node_modules
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# dotenv environment variables file
.env

# gatsby files
.cache/
public

# Mac files
.DS_Store
.idea

# Yarn
yarn-error.log
.pnp/
.pnp.js
# Yarn Integrity file
.yarn-integrity
1 change: 1 addition & 0 deletions packages/twentynineteen-gatsby-theme/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11.10.1
31 changes: 31 additions & 0 deletions packages/twentynineteen-gatsby-theme/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
*.min.js
**/node_modules/**
flow-typed

# webfont demo styles
**/specimen_files

# built sites
benchmarks/**/public
e2e-tests/**/public
examples/**/public
integration-tests/**/public
www/public

# cache-dirs
**/.cache

# ignore built packages
packages/**/*.js
!packages/gatsby/cache-dir/**/*.js
!packages/*/src/**/*.js
packages/gatsby/cache-dir/commonjs/**/*.js

# fixtures
**/__testfixtures__/**
**/__tests__/fixtures/**

infrastructure

# coverage
coverage
6 changes: 6 additions & 0 deletions packages/twentynineteen-gatsby-theme/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
5 changes: 5 additions & 0 deletions packages/twentynineteen-gatsby-theme/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
wordPressUrl: `https://demo.wpgraphql.com`,
};

export default config
17 changes: 12 additions & 5 deletions packages/twentynineteen-gatsby-theme/create/createPosts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
var axios = require("axios");
const axios = require("axios");

import config from '../config.js';
const { PostContentFragment } = require('../src/templates/Post/data');

module.exports = async ({ graphql, actions }) => {
const { createPage } = actions;
Expand All @@ -18,12 +21,15 @@ module.exports = async ({ graphql, actions }) => {
uri
title
content
...PostContentFragment
}
}
}
}`;
}
${PostContentFragment}
`;
const res = await axios({
url: "https://www.mtwoblog.com/graphql",
url: `${config.wordPressUrl}/graphql`,
method: "get",
params: {
QUERY: GET_POSTS
Expand All @@ -38,11 +44,12 @@ module.exports = async ({ graphql, actions }) => {
}
} = res.data;

const postTemplate = require.resolve(`../src/templates/post.js`);
const postTemplate = require.resolve(`../src/templates/Post`);

allPosts.map(post => {
post = post.node;
console.log(`create post: ${post.uri}`);
console.log( post );
createPage({
path: `/blog/${post.uri}/`,
component: postTemplate,
Expand All @@ -55,7 +62,7 @@ module.exports = async ({ graphql, actions }) => {
query GET_POSTS($first:Int $after:String){
wpgraphql {
posts(
first: $first
first: $first
after:$after
) {
pageInfo {
Expand Down
Loading

0 comments on commit 3074c22

Please sign in to comment.