Skip to content

Commit

Permalink
Merge branch 'master' into feat/no-watch-on-build
Browse files Browse the repository at this point in the history
* master: (35 commits)
  feat(gatsby-source-filesystem): keep original name of remote files (gatsbyjs#9777)
  docs(gatsby-source-contentful): Rewrite of gatsby-source-contentful query section (gatsbyjs#7533)
  Update "Deploying with Now" Guide (gatsbyjs#10390)
  Add Matomo to list of analytics plugins (gatsbyjs#10372)
  Add satispay.com to showcase (gatsbyjs#10380)
  Adds @goblindegook/gatsby-starter-typescript (gatsbyjs#10377)
  Fix typo in gatsby-remark-code-repls sample `gatsby-config.json` in README (gatsbyjs#10361)
  fix(gatsby): fix false type conflict warning on plugin fields (gatsbyjs#10355)
  fix(docs): Just a small typo fix in the docs (gatsbyjs#10359)
  feat(gatsby-image): add onStartLoad prop  (gatsbyjs#6702)
  fix(docs): add Ecosystem to docs sidebar, consistency with tutorial sidebar (gatsbyjs#10350)
  fix(www): Starters.yaml housekeeping (gatsbyjs#10354)
  docs: add ttag starter (gatsbyjs#10352)
  docs: document branching (gatsbyjs#9983)
  plugin checker initial commit (gatsbyjs#7062)
  docs: new starter features is required (gatsbyjs#10353)
  docs: migrated line highlighting to highlight-line, highlight-start, highlight-end (gatsbyjs#10202)
  Add Birra Napoli to site showcase (gatsbyjs#10344)
  Add BetterDocs to site showcase (gatsbyjs#10349)
  chore(release): Publish
  ...
  • Loading branch information
m-allanson committed Dec 10, 2018
2 parents 3f5b24a + dfc069d commit 9b710e7
Show file tree
Hide file tree
Showing 122 changed files with 3,244 additions and 453 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ appveyor.yml @gatsbyjs/core

# The ecosystem files are error-prone, so we require an extra set of eyes on them.
/docs/* @gatsbyjs/ecosystem
/docs/creators/* @gatsbyjs/ecosystem
/docs/creators/images/* @gatsbyjs/ecosystem

# The website auto-deploys, so we need an extra check to avoid shenanigans.
/www/ @gatsbyjs/website
24 changes: 18 additions & 6 deletions docs/blog/2017-07-19-creating-a-blog-with-gatsby/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ After installing each of these functional plugins, we'll edit
`gatsby-config.js`, which Gatsby loads at build-time to implement the exposed
functionality of the specified plugins.

```javascript{6-9}:title=gatsby-config.js
```javascript:title=gatsby-config.js
module.exports = {
siteMetadata: {
title: `Your Name - Blog`,
author: `Your Name`,
},
// highlight-start
plugins: ["gatsby-plugin-catch-links", "gatsby-plugin-react-helmet"],
}
// highlight-end
```

Without any additional work besides a `yarn install` and editing a config file,
Expand All @@ -127,19 +129,21 @@ into our `gatsby-config.js`, like so:
yarn add gatsby-source-filesystem
```

```javascript{6-12}:title=gatsby-config.js
```javascript:title=gatsby-config.js
module.exports = {
// previous configuration
plugins: [
"gatsby-plugin-catch-links",
"gatsby-plugin-react-helmet",
// highlight-start
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/pages`,
name: "pages",
},
},
// highlight-end
],
}
```
Expand Down Expand Up @@ -178,7 +182,7 @@ yarn add gatsby-transformer-remark

and editing `gatsby-config.js`

```javascript{13-18}:title=gatsby-config.js
```javascript:title=gatsby-config.js
module.exports = {
// previous setup
plugins: [
Expand All @@ -191,12 +195,14 @@ module.exports = {
name: "pages",
},
},
// highlight-start
{
resolve: "gatsby-transformer-remark",
options: {
plugins: [], // just in case those previously mentioned remark plugins sound cool :)
},
},
// highlight-end
],
}
```
Expand Down Expand Up @@ -294,7 +300,7 @@ very simply the pieces of data that we want to display for our blog post. Each
piece of data our query selects will be injected via the `data` property we
specified earlier.

```javascript{23-32}:title=src/templates/blog-post.js
```javascript:title=src/templates/blog-post.js
import React from "react"
import Helmet from "react-helmet"
import { graphql } from "gatsby"
Expand All @@ -317,6 +323,7 @@ export default function Template({ data }) {
)
}

// highlight-start
export const pageQuery = graphql`
query BlogPostByPath($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
Expand All @@ -329,6 +336,7 @@ export const pageQuery = graphql`
}
}
`
// highlight-end
```

If you're not familiar with GraphQL, this may seem slightly confusing, but we can
Expand Down Expand Up @@ -398,14 +406,15 @@ query, which will fetch all of our Markdown posts.

### Querying for posts

```javascript{8-31}:title=gatsby-node.js
```javascript:title=gatsby-node.js
const path = require("path")

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

const blogPostTemplate = path.resolve(`src/templates/blog-post.js`)

// highlight-start
return graphql(`
{
allMarkdownRemark(
Expand All @@ -427,6 +436,7 @@ exports.createPages = ({ actions, graphql }) => {
}
})
}
// highlight-end
```

We're using GraphQL to get all Markdown nodes and making them available under
Expand All @@ -447,7 +457,7 @@ pages (with the `createPage` action creator). Let's do that!

### Creating the pages

```javascript{28-34}:title=gatsby-node.js
```javascript:title=gatsby-node.js
const path = require("path")

exports.createPages = ({ actions, graphql }) => {
Expand Down Expand Up @@ -475,13 +485,15 @@ exports.createPages = ({ actions, graphql }) => {
return Promise.reject(result.errors)
}

// highlight-start
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: blogPostTemplate,
context: {}, // additional data can be passed via context
})
})
// highlight-end
})
}
```
Expand Down
34 changes: 22 additions & 12 deletions docs/blog/2018-10-25-unstructured-data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ That's it!

By [exporting `createPages`](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L21) from our example Gatsby site's `gatsby-node.js` file, we're saying, "at this point in the bootstrapping sequence, run this code".

```javascript{1,3}:title=gatsby-node.js
```javascript:title=gatsby-node.js
// highlight-next-line
exports.createPages = () => {
// Run this code
}
} // highlight-line
```

#### 2. [Fetch the data](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L22) from the PokéAPI.

```javascript{2}:title=gatsby-node.js
```javascript:title=gatsby-node.js
exports.createPages = async () => {
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"])
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"]) // highlight-line
}
```

Expand All @@ -76,24 +77,27 @@ _Note: [`getPokemonData`](https://github.com/jlengstorf/gatsby-with-unstructured

When you hook into a Gatsby API (like `createPages` from step one), you are passed a collection of actions. In this example, we're extracting the [`createPage` action](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L21) using ES6 object destructuring:

```javascript{1}:title=gatsby-node.js
```javascript:title=gatsby-node.js
// highlight-next-line
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"])
}
```

#### 4. Create a page that [lists all Pokémon](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L25).

```javascript{4-9}:title=gatsby-node.js
```javascript:title=gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"])

// highlight-start
// Create a page that lists all Pokémon.
createPage({
path: `/`,
component: require.resolve("./src/templates/all-pokemon.js"),
context: { allPokemon },
})
// highlight-end
}
```

Expand All @@ -105,21 +109,23 @@ The [`createPage` action](/docs/actions/#createPage) is passed an object contain

In our example, we're accessing the context as [props to the component](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/src/templates/all-pokemon.js#L4). This allows us to completely circumvent Gatsby’s data layer; it’s just props.

```jsx{1,3,5,12-14}:title=src/templates/all-pokemon.js
export default ({ pageContext: { allPokemon } }) => (
```jsx:title=src/templates/all-pokemon.js
export default ({ pageContext: { allPokemon } }) => (// highlight-line
{...}
{allPokemon.map(pokemon => (
{allPokemon.map(pokemon => ( // highlight-line
<li
key={pokemon.id}
key={pokemon.id} {/* highlight-line */}
style={{
textAlign: 'center',
listStyle: 'none',
display: 'inline-block'
}}
>
{/* highlight-start */}
<Link to={`/pokemon/${pokemon.name}`}>
<img src={pokemon.sprites.front_default} alt={pokemon.name} />
<p>{pokemon.name}</p>
{/* highlight-end */}
</Link>
</li>
))}
Expand All @@ -129,7 +135,7 @@ export default ({ pageContext: { allPokemon } }) => (

#### 5. Create a page [for each Pokémon](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L32).

```javascript{11-18}:title=gatsby-node.js
```javascript:title=gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"])

Expand All @@ -140,6 +146,7 @@ exports.createPages = async ({ actions: { createPage } }) => {
context: { allPokemon },
})

// highlight-start
// Create a page for each Pokémon.
allPokemon.forEach(pokemon => {
createPage({
Expand All @@ -148,12 +155,13 @@ exports.createPages = async ({ actions: { createPage } }) => {
context: { pokemon },
})
})
// highlight-end
}
```

#### 6. Create a page [for each ability of each Pokémon](https://github.com/jlengstorf/gatsby-with-unstructured-data/blob/0a91d87b9d4d24a0e6b04b33cc271e054b7467b6/gatsby-node.js#L40).

```javascript{19-26}:title=gatsby-node.js
```javascript:title=gatsby-node.js
exports.createPages = async ({ actions: { createPage } }) => {
const allPokemon = await getPokemonData(["pikachu", "charizard", "squirtle"])

Expand All @@ -172,6 +180,7 @@ exports.createPages = async ({ actions: { createPage } }) => {
context: { pokemon },
})

// highlight-start
// Create a page for each ability of the current Pokémon.
pokemon.abilities.forEach(ability => {
createPage({
Expand All @@ -180,6 +189,7 @@ exports.createPages = async ({ actions: { createPage } }) => {
context: { pokemon, ability },
})
})
// highlight-end
})
}
```
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 2 additions & 0 deletions docs/docs/add-offline-support-with-a-service-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Add this plugin to your `gatsby-config.js`

That's all you need to add offline support to your Gatsby site.

Note: Service worker registers only in production builds (`gatsby build`).

## References

- [Service Workers: an Introduction](https://developers.google.com/web/fundamentals/primers/service-workers/)
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/add-page-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ npm install --save gatsby-plugin-react-helmet react-helmet

3. Use `React Helmet` in your pages:

```jsx{8-12}
```jsx
import React from "react"
import { Helmet } from "react-helmet"

class Application extends React.Component {
render() {
return (
<div className="application">
{/* highlight-start */}
<Helmet>
<meta charSet="utf-8" />
<title>My Title</title>
<link rel="canonical" href="http://mysite.com/example" />
</Helmet>
...
{/* highlight-end */}
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions docs/docs/adding-analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ Once this is configured you can deploy your site to test! If you navigate to the
- [Amplitude Analytics](/packages/gatsby-plugin-amplitude-analytics)
- [Fathom](/packages/gatsby-plugin-fathom/)
- [Baidu](/packages/gatsby-plugin-baidu-analytics/)
- [Matomo (formerly Piwik)](/packages/gatsby-plugin-matomo/)
8 changes: 6 additions & 2 deletions docs/docs/adding-pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The information needed to query for those specific items (i.e. values for [`limi

### Example

```js{20-25}:title=src/templates/blog-list-template.js
```js:title=src/templates/blog-list-template.js
import React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
Expand All @@ -33,12 +33,14 @@ export default class BlogList extends React.Component {
}

export const blogListQuery = graphql`
// highlight-start
query blogListQuery($skip: Int!, $limit: Int!) {
allMarkdownRemark(
sort: { fields: [frontmatter___date], order: DESC }
limit: $limit
skip: $skip
) {
// highlight-end
edges {
node {
fields {
Expand All @@ -54,7 +56,7 @@ export const blogListQuery = graphql`
`
```

```js{34-47}:title=gatsby-node.js
```js:title=gatsby-node.js
const path = require("path")
const { createFilePath } = require("gatsby-source-filesystem")

Expand Down Expand Up @@ -88,6 +90,7 @@ exports.createPages = ({ graphql, actions }) => {
// ...

// Create blog-list pages
// highlight-start
const posts = result.data.allMarkdownRemark.edges
const postsPerPage = 6
const numPages = Math.ceil(posts.length / postsPerPage)
Expand All @@ -102,6 +105,7 @@ exports.createPages = ({ graphql, actions }) => {
},
})
})
// highlight-end
})
)
})
Expand Down
Loading

0 comments on commit 9b710e7

Please sign in to comment.