Skip to content

Migrate to Gatsby 🚀 #913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public
node_modules
54 changes: 54 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": ["airbnb"],
"parser": "babel-eslint",
"rules": {
"array-bracket-spacing": ["error","always"],
"computed-property-spacing": ["error","always"],
"func-names": ["error","never"],
"semi": ["error","never"],
"semi-style": ["error","first"],
"import/extensions": 0,
"import/no-unresolved": 0,
"import/prefer-default-export": 0,
"jsx-a11y/anchor-is-valid": 0,
"import/no-extraneous-dependencies": 0,
"linebreak-style": 0,
"no-await-in-loop": 0,
"no-loop-func": 0,
"no-restricted-syntax": 0,
"no-shadow": 0,
"no-unused-vars": 1,
"react/jsx-filename-extension": 0,
"react/state-in-constructor": 0,
"react/jsx-props-no-spreading": 0,
"react/sort-comp": 0,
"react/jsx-one-expression-per-line": 0,
"space-in-parens": [
"error",
"always",
{
"exceptions": [
"empty"
]
}
],
"object-curly-newline": [
"error",
{
"consistent": true
}
],
"arrow-parens": [
"error",
"as-needed",
{
"requireForBlockBody": false
}
]
}
}
75 changes: 67 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,69 @@
*.swp
*~
# 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 variable files
.env*

# gatsby files
.cache/
public

# Mac files
.DS_Store
.nvmrc
node_modules
npm-debug.log

/build/
.tmp.*
package-lock.json
# Yarn
yarn-error.log
.pnp/
.pnp.js
# Yarn Integrity file
.yarn-integrity
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

26 changes: 0 additions & 26 deletions LICENSE

This file was deleted.

34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# Contributing

Organization gh-pages deploy the `master` branch, so active development occurs
on this `source` branch.
Created using [`gastby-starter-default`](https://github.com/gatsbyjs/gatsby-starter-default)

The site is written in JS and Markdown files in `site/`.
### Prerequisites
* [Git](https://git-scm.com/)
* [Node.JS](https://nodejs.org/en/) x64, version `>= 12.x`

The site chrome are all in JS files in `site/_core/`.
## Development Setup
* Install dependencies:
```
npm install
```
* Run the development server
```
npm start
```
:rocket: Development server -> http://localhost:8000

### Making changes

The first time, get all the dependencies loaded via
All the docs live in `src/content`. Relative paths can be used for images.

`$ npm install` or `$ yarn install`

Then, run the server via

`$ npm start` or `$ yarn start`

Open [http://localhost:8444](http://localhost:8444) to view it in the browser.
Anytime you make some changes, refresh the page to see the updates.

### Publish the Website

Once pushed to the `source` branch, Travis CI will publish http://graphql.org
`src/img` has sub-directories to help organize images.
1 change: 1 addition & 0 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/css/style.less'
112 changes: 112 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
module.exports = {
siteMetadata: {
title: 'GraphQL',
description: 'Gatsby Site for GraphQL.org',
siteUrl: 'http://graphql.org',
},
plugins: [
'gatsby-plugin-react-helmet',
'gatsby-plugin-less',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/img`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'content',
path: `${__dirname}/src/content`,
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'graphql-docs',
short_name: 'graphql',
start_url: '/',
icon: 'src/img/favicon.png',
},
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
'gatsby-remark-autolink-headers',
{
resolve: 'gatsby-remark-prismjs',
options: {
classPrefix: 'prism language-',
},
},
{
resolve: 'gatsby-remark-images-anywhere',
options: {
staticDir: 'src/img',
},
},
],
},
},
{
resolve: 'gatsby-plugin-feed',
options: {
query: `
{
site {
siteMetadata {
siteUrl
}
}
}
`,
feeds: [
{
serialize: ( {
query: { site, allMarkdownRemark },
} ) => allMarkdownRemark.edges.map( ( {
node: {
excerpt,
frontmatter: { title, date, permalink, byline },
},
} ) => ( {
title,
date,
url: site.siteMetadata.siteUrl + permalink,
description: excerpt,
author: byline,
} ) ),
query: `
{
allMarkdownRemark(
filter: {frontmatter: {layout: {eq: "BlogPostLayout"}}},
sort: { order: DESC, fields: [frontmatter___date] }
) {
edges {
node {
excerpt
frontmatter {
title
date
permalink
byline
}
}
}
}
}
`,
output: '/blog/rss.xml',
title: 'Blog | GraphQL',
feed_url: 'http://graphql.org/blog/rss.xml',
site_url: 'http://graphql.org',
},
],
},
},
],
}
39 changes: 39 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require( 'path' )

exports.createPages = async ( { actions, graphql, reporter } ) => {
const { createPage } = actions

const result = await graphql( `
query AllContentPages {
allMarkdownRemark {
edges {
node {
id
frontmatter {
layout
permalink
}
}
}
}
}
` )

if ( result.errors ) reporter.panicOnBuild( '🚨 ERROR: Loading "createPages" query' )

const pages = result.data.allMarkdownRemark.edges

// Call `createPage` for each page
pages
.filter( ( { node: { frontmatter: { layout } } } ) => layout )
.forEach( ( { node: {
id,
frontmatter: { layout, permalink },
} } ) => {
createPage( {
path: permalink,
component: path.resolve( `src/templates/${layout}.js` ),
context: { id },
} )
} )
}
Loading