Skip to content
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

[v2] prettier #5105

Merged
merged 2 commits into from
Apr 24, 2018
Merged
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 data-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a manual edit... should this file be deleted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's really old file with some notes I made early in v1.

new SourceDirectory({
parsers: [
{
Expand All @@ -12,6 +13,7 @@ new SourceDirectory({
},
]
})
```

Just copy Jekyll?

Expand Down
65 changes: 31 additions & 34 deletions docs/blog/2018-04-04-gatsby-contentful-starter-tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@ This piece will walk you through getting your GatsbyJS website up and running wi

Here’s an overview of what’s involved:

- Create a free Contentful account
- Clone a sample repo
- Create a space on Contentful to store content
- Generate your Content Management and Content Delivery API access tokens
- Import data into your space
- Tweak your configuration file
- Preview a production build
- Publish and go live
* Create a free Contentful account
* Clone a sample repo
* Create a space on Contentful to store content
* Generate your Content Management and Content Delivery API access tokens
* Import data into your space
* Tweak your configuration file
* Preview a production build
* Publish and go live

###Getting started

This guide assumes that you have [GatsbyJS installed](/docs/) and, optionally, a [Github account](https://github.com/join). You will also need a free Contentful account - [creating one](https://www.contentful.com/sign-up/) only takes a moment.

Start by using this with the Gatsby CLI:

~~~bash
```bash
gatsby new contentful-starter https://github.com/contentful-userland/gatsby-contentful-starter
~~~
```

Alternatively, you can also clone a sample repo from Github:

~~~bash
```bash
git clone [email protected]:contentful-userland/gatsby-contentful-starter.git
~~~
```

And go into the directory and install the required dependencies with:

~~~bash
```bash
npm install
~~~
```

###Create a new space to store content

Expand All @@ -56,15 +56,13 @@ Create a new empty space by opening the sidebar menu and adding a Space. Give th

![create a new space](new_space.png)



###Generate access tokens

Before getting to the exciting part of setting up your website, you first need to generate three access tokens to get your Contentful-powered website up and running by fetching data from the API.

- [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/)
- [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/)
- [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/)
* [Content Management API](https://www.contentful.com/developers/docs/references/content-management-api/)
* [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/)
* [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/)

Head over to your Space Settings dropdown menu and navigate to the APIs section. From there, navigate to the tab for the API token you would like to generate.

Expand All @@ -84,20 +82,19 @@ Start setting things up with the npm run setup command, which first prompts you

After that, it writes the credentials you provided into a file named .contentful.json into lines of code that look like so:


~~~json
{
"development":{
"host":"preview.contentful.com",
"spaceId":"...",
"accessToken":"..."
},
"production":{
"spaceId":"...",
"accessToken":"..."
}
```json
{
"development": {
"host": "preview.contentful.com",
"spaceId": "...",
"accessToken": "..."
},
"production": {
"spaceId": "...",
"accessToken": "..."
}
}
~~~
```

Using the credentials in the .contentful.json file, [content can now be imported](https://www.contentful.com/developers/docs/tutorials/general/import-and-export/) into your space to being displayed on your website via our API.

Expand All @@ -119,6 +116,6 @@ Contentful ensures your website and its users can access your content quickly an

That’s a quick overview of how to get your website up and running from scratch using Contentful and GatsbyJS.

Contentful's platform offers speed, flexibility, and ease of integration with your code, supporting any stack you use with SDKs for common languages like [Javascript](https://www.contentful.com/developers/docs/javascript/sdks/), [Python](https://www.contentful.com/developers/docs/python/sdks/), and [PHP](https://www.contentful.com/developers/docs/php/sdks/). Unlike a CMS, Contentful provides you with separation between content and presentation, allowing you to focus on developing your website and leave content delivery to Contentful.
Contentful's platform offers speed, flexibility, and ease of integration with your code, supporting any stack you use with SDKs for common languages like [Javascript](https://www.contentful.com/developers/docs/javascript/sdks/), [Python](https://www.contentful.com/developers/docs/python/sdks/), and [PHP](https://www.contentful.com/developers/docs/php/sdks/). Unlike a CMS, Contentful provides you with separation between content and presentation, allowing you to focus on developing your website and leave content delivery to Contentful.

If you're curious to learn more about Contentful, you can check out the Contentful [Developer Center](https://www.contentful.com/developers/docs/) to learn more on how the technology works, or head over to the [Guides and tutorials](https://www.contentful.com/guides/) section.
If you're curious to learn more about Contentful, you can check out the Contentful [Developer Center](https://www.contentful.com/developers/docs/) to learn more on how the technology works, or head over to the [Guides and tutorials](https://www.contentful.com/guides/) section.
6 changes: 3 additions & 3 deletions docs/blog/2018-04-05-gatsby-video-tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ _This blog post was originally posted on the [Contentful Blog](https://www.conte

Contentful developer and Gatsby contributor Khaled Garbaya has released a [4-part video series](https://www.youtube.com/watch?v=Ek4o40w1tH4&list=PL8KiuH6vpACV-F7jXribe4YveGBhBeG9A) to help you build a “blazing fast” website with Gatsby and Contentful. The series begins by transforming the Gatsby’s getting started example to a Contentful-powered site. From there, each video walks you through a new aspect of production, from automating deployment with CircleCI to integrating the Contentful webhooks feature.

*-“I wanted these videos to act as documentation,”* says Khaled. *-“There were a lot of people asking around about how to do this. And I think it’s important to show not only how to do this thing with Gatsby or how to do that with Contentful, but from start to finish how you can actually deploy, use webhooks, and so on. These are hidden gems that not everyone will look for.”*
_-“I wanted these videos to act as documentation,”_ says Khaled. _-“There were a lot of people asking around about how to do this. And I think it’s important to show not only how to do this thing with Gatsby or how to do that with Contentful, but from start to finish how you can actually deploy, use webhooks, and so on. These are hidden gems that not everyone will look for.”_

Those hidden gems Khaled is talking about are part of what he believes makes Gatsby and Contentful a compelling combination. Additionally, there are structural aspects of both platforms that add to this: *-“Gatsby works with React and React is component-based. And you can also think of Contentful in this way, if you think of your content as components”* he explains. *-“So that’s made a really perfect match because you can have this component that renders a specific content type and then this can be shared across your website.”*
Those hidden gems Khaled is talking about are part of what he believes makes Gatsby and Contentful a compelling combination. Additionally, there are structural aspects of both platforms that add to this: _-“Gatsby works with React and React is component-based. And you can also think of Contentful in this way, if you think of your content as components”_ he explains. _-“So that’s made a really perfect match because you can have this component that renders a specific content type and then this can be shared across your website.”_

Another unique distinction is the complementary ways Contentful and Gatsby process data. *-“Contentful has the sync endpoint, so this can actually improve the ability to process a lot,”* Khaled says. *-“Because the first time, you get all of the data. The next time, you only get the entries that changed so it takes less time to parse the JSON and so on. Also Gatsby is good because all of the data you have from Contentful would be in a GraphQL schema, so you can query your data that way.”*
Another unique distinction is the complementary ways Contentful and Gatsby process data. _-“Contentful has the sync endpoint, so this can actually improve the ability to process a lot,”_ Khaled says. _-“Because the first time, you get all of the data. The next time, you only get the entries that changed so it takes less time to parse the JSON and so on. Also Gatsby is good because all of the data you have from Contentful would be in a GraphQL schema, so you can query your data that way.”_

Ready to dive in? [All four parts of Khaled’s video series are now available on YouTube](https://www.youtube.com/watch?v=Ek4o40w1tH4&list=PL8KiuH6vpACV-F7jXribe4YveGBhBeG9A). You can also [find the source code on GitHub](https://github.com/Khaledgarbaya/gatsby-contentful-site).

Expand Down
14 changes: 7 additions & 7 deletions docs/docs/add-custom-webpack-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ you to modify the default webpack config using
Gatsby does multiple webpack builds with somewhat different configuration. We
call each build type a "stage". The following stages exist:

1. develop: when running the `gatsby develop` command. Has configuration for hot
reloading and CSS injection into page
2. develop-html: same as develop but without react-hmre in the babel config for
rendering the HTML component.
3. build-javascript: production JavaScript and CSS build. Creates route JS bundles as well
as commons chunks for JS and CSS.
4. build-html: production build static HTML pages
1. develop: when running the `gatsby develop` command. Has configuration for hot
reloading and CSS injection into page
2. develop-html: same as develop but without react-hmre in the babel config for
rendering the HTML component.
3. build-javascript: production JavaScript and CSS build. Creates route JS bundles as well
as commons chunks for JS and CSS.
4. build-html: production build static HTML pages

Check
[webpack.config.js](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/webpack.config.js)
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/debugging-html-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
{
test: /bad-module/,
use: loaders.null(),
}
]
}
})
},
],
},
});
}
};
```
4 changes: 2 additions & 2 deletions docs/docs/gatsby-starters.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ Community:
Features:

* localization (Multilanguage)

* [gatsby-starter-datocms](https://github.com/datocms/gatsby-portfolio)
[(demo)](http://cranky-edison-12166d.netlify.com/)

Features:

* Simple portfolio to quick start a site with DatoCMS
* Contents and media from DatoCMS
* Custom sass style
Expand Down
1 change: 0 additions & 1 deletion docs/tutorial/part-two/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ While we won't cover CSS-in-JS in this initial tutorial, we encourage you to exp
as well as
[Mark Dalgleish's more recent post "A Unified Styling Language"](https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660).


### CSS Modules

Let's explore **CSS Modules**.
Expand Down
2 changes: 1 addition & 1 deletion examples/gatsbygram/src/layouts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { rhythm, scale } from "../utils/typography"
import presets from "../utils/presets"

let Modal
import("../components/modal").then(modal => {
import(`../components/modal`).then(modal => {
Modal = modal.default
})

Expand Down
3 changes: 0 additions & 3 deletions examples/simple-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@
"develop": "gatsby develop",
"format": "prettier --write 'src/**/*.js'",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"prettier": "^1.11.1"
}
}
10 changes: 3 additions & 7 deletions examples/using-faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@
"react-dom": "^16.3.2",
"react-helmet": "^5.2.0"
},
"keywords": [
"gatsby"
],
"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\"",
"format":
"prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"prettier": "^1.9.2"
}
}
12 changes: 4 additions & 8 deletions examples/using-page-transitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
"react-helmet": "^5.2.0",
"react-transition-group": "^2.2.1"
},
"keywords": [
"gatsby"
],
"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'",
"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"
}
}
}
14 changes: 8 additions & 6 deletions examples/using-remark-copy-linked-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@
"devDependencies": {
"eslint": "^4.9.0",
"eslint-plugin-react": "^7.4.0",
"gh-pages": "^0.12.0",
"prettier": "^1.8.1"
"gh-pages": "^0.12.0"
},
"license": "MIT",
"main": "n/a",
"scripts": {
"dev": "gatsby develop",
"lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
"lint":
"./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'",
"format":
"prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'",
"develop": "gatsby develop",
"build": "gatsby build",
"deploy": "gatsby build --prefix-paths && gh-pages -d public",
"fix-semi": "eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js"
"fix-semi":
"eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js"
}
}
}
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"cross-env": "^5.1.4",
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"eslint-config-prettier": "^2.5.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flow-vars": "^0.5.0",
"eslint-plugin-flowtype": "^2.46.1",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.7.0",
"flow-bin": "^0.42.0",
"glob": "^7.1.1",
Expand All @@ -28,7 +28,7 @@
"lerna": "^2.1.1",
"npm-run-all": "4.1.2",
"plop": "^1.8.1",
"prettier": "^1.11.1",
"prettier": "^1.12",
"prettier-eslint-cli": "4.7.1",
"remotedev-server": "^0.2.3",
"rimraf": "^2.6.1",
Expand All @@ -37,17 +37,17 @@
"engines": {
"yarn": "^1.2.1"
},
"eslintIgnore": [
"interfaces",
"**/__tests__/fixtures/"
],
"eslintIgnore": ["interfaces", "**/__tests__/fixtures/"],
"private": true,
"scripts": {
"bootstrap": "npm-run-all -s check-versions lerna-prepublish",
"check-versions": "babel-node scripts/check-versions.js",
"format": "npm-run-all -p format-packages format-cache-dir format-www format-examples format-scripts format-markdown",
"format-cache-dir": "prettier-eslint --write \"packages/gatsby/cache-dir/*.js\"",
"format-examples": "prettier-eslint --write \"examples/**/gatsby-node.js\" \"examples/**/gatsby-config.js\" \"examples/**/src/**/*.js\"",
"format":
"npm-run-all -p format-packages format-cache-dir format-www format-examples format-scripts format-markdown",
"format-cache-dir":
"prettier-eslint --write \"packages/gatsby/cache-dir/*.js\"",
"format-examples":
"prettier-eslint --write \"examples/**/gatsby-node.js\" \"examples/**/gatsby-config.js\" \"examples/**/src/**/*.js\"",
"format-markdown": "prettier --write \"**/*.md\" --semi",
"format-packages": "prettier-eslint --write \"packages/*/src/**/*.js\"",
"format-scripts": "prettier-eslint --write \"scripts/**/*.js\"",
Expand All @@ -69,7 +69,5 @@
"test_bkup": "npm-run-all -s lint test-node test-integration",
"watch": "lerna run watch --no-sort --stream --concurrency 999"
},
"workspaces": [
"packages/*"
]
"workspaces": ["packages/*"]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const babel = require("babel-core")
const reactPreset = require("@babel/preset-react")
const plugin = require("../")
const babel = require(`babel-core`)
const reactPreset = require(`@babel/preset-react`)
const plugin = require(`../`)

var staticQuery = `
import React from 'react'
Expand Down Expand Up @@ -28,15 +28,15 @@ export const query = graphql\`
\`
`

it("Transforms queries in <StaticQuery>", () => {
it(`Transforms queries in <StaticQuery>`, () => {
const { code } = babel.transform(staticQuery, {
presets: [reactPreset],
plugins: [plugin],
})
expect(code).toMatchSnapshot()
})

it("Transforms queries in page components", () => {
it(`Transforms queries in page components`, () => {
const { code } = babel.transform(pageComponent, {
presets: [reactPreset],
plugins: [plugin],
Expand Down
Loading