Skip to content

Commit

Permalink
Merge branch 'master' into gatsby-source-medium/fetch-users-and-publi…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
racedale committed Jan 20, 2018
2 parents 6507299 + f0f0040 commit b599aab
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 90 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Websites built with Gatsby:
* [Landing page of Put.io](https://put.io/)
* [Ryan Wiemer's Portfolio](https://www.ryanwiemer.com)
([source](https://github.com/ryanwiemer/rw))
* [yerevancoder](https://yerevancoder.com)
([source](https://github.com/yerevancoder/yerevancoder.github.io))

## Docs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Today, the team and the city scored a huge victory when Amazon announced that Bo

![Amazon Boston homepage](./amazon-boston.jpg "Boston city")

When Amazon announced in September that it was looking to build a new headquarters, bringing 50,000 jobs and billions of investment to the chosen city, Boston’s city government jumped to throw their hat in the ring.
When Amazon announced in September that it was looking to build a new headquarters, bringing 50,000 jobs and billions of investment to the chosen city, Boston’s city government jumped to throw their hat in the ring.

As a technology hub, the city wanted to put their best digital foot forward, so they turned to the Boston.gov team to build a website as the city’s application — [amazon.boston.gov](http://amazon.boston.gov) .

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/building-apps-with-gatsby.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Building apps with Gatsby"
---

Gatsby can be used to create fully dynamic apps. The default Gatsby app is made up of statically rendered pages. On this foundation, you can build what we call "hybrid" sites which adds dynamically rendered sections of pages and if needed, client-only routes.
Gatsby can be used to create fully dynamic apps. The default Gatsby app is made up of statically rendered pages. On this foundation, you can build what we call "hybrid" sites which adds dynamically rendered sections of pages and if needed, client-only routes.

## Statically rendered pages

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/gatsby-starters.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Community:
* Basic components: SiteNavi, SitePost, SitePage

* [gatsby-blog-starter-kit](https://github.com/dschau/gatsby-blog-starter-kit)
[(demo)](https://dschau.github.io/gatsby-blog-starter-kit/)
[(demo)](https://dschau.github.io/gatsby-blog-starter-kit/)

Features:

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/querying-with-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ the browser when needed by your components.
## Why is GraphQL so cool?

* Eliminate frontend data boilerplate — no need to worry about requesting & waiting for data. Just ask for the data you need with a GraphQL query and it'll show up when you need it
* Push frontend complexity into queries — many data transformations can be done at *build-time* within your GraphQL queries
* Push frontend complexity into queries — many data transformations can be done at _build-time_ within your GraphQL queries
* It's the perfect data querying language for the often complex/nested data dependencies of modern applications
* Improve performance by removing data bloat — GraphQL is a big part of why Gatsby is so fast as it enables lazy-loading the exact data in the exact form each view needs

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-netlify-cms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-netlify-cms",
"version": "1.0.2",
"version": "1.0.4",
"description": "A Gatsby plugin which generates the Netlify CMS single page app",
"main": "index.js",
"author": "Shawn Erquhart <shawn@erquh.art>",
Expand Down
80 changes: 58 additions & 22 deletions packages/gatsby-plugin-netlify-cms/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
const HtmlWebpackPlugin = require(`html-webpack-plugin`)
const HtmlWebpackIncludeAssetsPlugin = require(`html-webpack-include-assets-plugin`)
const ExtractTextPlugin = require(`extract-text-webpack-plugin`)

function plugins(stage) {
const commonPlugins = [
// Output /admin/index.html
new HtmlWebpackPlugin({
title: `Content Manager`,
filename: `admin/index.html`,
chunks: [`cms`],
}),

// Include the identity widget script in the html file
new HtmlWebpackIncludeAssetsPlugin({
assets: [`https://identity.netlify.com/v1/netlify-identity-widget.js`],
append: false,
publicPath: false,
}),
]

exports.modifyWebpackConfig = (
{ config, stage },
{ modulePath = `${__dirname}/cms.js` }
) => {
switch (stage) {
case `develop`:
return commonPlugins
case `build-javascript`:
return [...commonPlugins, new ExtractTextPlugin(`cms.css`)]
default:
return []
}
}

function module(config, stage) {
switch (stage) {
case `build-javascript`:
config.merge({
entry: {
cms: modulePath,
},
plugins: [
new HtmlWebpackPlugin({
title: `Content Manager`,
filename: `admin/index.html`,
chunks: [`cms`],
}),
new HtmlWebpackIncludeAssetsPlugin({
assets: [
`https://identity.netlify.com/v1/netlify-identity-widget.js`,
],
append: false,
publicPath: false,
}),
],
// Exclude Netlify CMS styles from Gatsby CSS bundle. This relies on
// Gatsby using webpack-configurator for webpack config extension, and
// also on the target loader key being named "css" in Gatsby's webpack
// config.
config.loader(`css`, {
exclude: [/\/node_modules\/netlify-cms\//],
})

// Exclusively extract Netlify CMS styles to /cms.css (filename configured
// above with plugin instantiation).
config.loader(`cms-css`, {
test: /\.css$/,
include: [/\/node_modules\/netlify-cms\//],
loader: ExtractTextPlugin.extract([`css`]),
})
return config
default:
return config
}
}

exports.modifyWebpackConfig = (
{ config, stage },
{ modulePath = `${__dirname}/cms.js` }
) => {
config.merge({
entry: {
cms: modulePath,
},
plugins: plugins(stage),
})

module(config, stage)

return config
}
2 changes: 1 addition & 1 deletion packages/gatsby-remark-images/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-remark-images",
"version": "1.5.37",
"version": "1.5.39",
"description": "Processes images in markdown so they can be used in the production build.",
"main": "index.js",
"keywords": [
Expand Down
3 changes: 1 addition & 2 deletions packages/gatsby-remark-images/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ test(`it leaves non-relative HTML img tags alone`, async () => {
`.trim()

const nodes = await plugin(createPluginOptions(content, imagePath))

expect(nodes.length).toBe(0)
expect(nodes[0].value).toBe(content)
})
21 changes: 14 additions & 7 deletions packages/gatsby-remark-images/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = (
}
return null
})

if (!imageNode || !imageNode.absolutePath) {
return resolve()
}
Expand Down Expand Up @@ -141,9 +142,12 @@ module.exports = (
fileType !== `svg`
) {
const rawHTML = await generateImagesAndUpdateNode(node, resolve)
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML

if (rawHTML) {
// Replace the image node with an inline HTML node.
node.type = `html`
node.value = rawHTML
}
return resolve(node)
} else {
// Image isn't relative so there's nothing for us to do.
Expand Down Expand Up @@ -197,10 +201,13 @@ module.exports = (
formattedImgTag,
resolve
)
// Replace the image string
thisImg.replaceWith(rawHTML)
} else {
return resolve()

if (rawHTML) {
// Replace the image string
thisImg.replaceWith(rawHTML)
} else {
return resolve()
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-drupal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-source-drupal",
"version": "2.0.12",
"version": "2.0.15",
"description": "Gatsby source plugin for building websites using the Drupal CMS as a data source",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
Expand All @@ -18,7 +18,7 @@
"axios": "^0.16.1",
"babel-runtime": "^6.26.0",
"bluebird": "^3.5.0",
"gatsby-source-filesystem": "^1.5.11",
"gatsby-source-filesystem": "^1.5.14",
"lodash": "^4.17.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-filesystem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-source-filesystem",
"version": "1.5.11",
"version": "1.5.14",
"description": "Gatsby plugin which parses files within a directory for further parsing by other plugins",
"license": "MIT",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions packages/gatsby-source-filesystem/src/create-remote-file-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { isWebUri } = require(`valid-url`)
const { createFileNode } = require(`./create-file-node`)
const cacheId = url => `create-remote-file-node-${url}`

module.exports = ({ url, store, cache, createNode }) =>
module.exports = ({ url, store, cache, createNode, auth = {} }) =>
new Promise(async (resolve, reject) => {
if (!url || isWebUri(url) === undefined) {
resolve()
Expand All @@ -27,6 +27,13 @@ module.exports = ({ url, store, cache, createNode }) =>
// from a previous request.
const cachedHeaders = await cache.get(cacheId(url))
const headers = {}

// Add htaccess authentication if passed in. This isn't particularly
// extensible. We should define a proper API that we validate.
if (auth && auth.htaccess_pass && auth.htaccess_user) {
headers.auth = `${auth.htaccess_user}:${auth.htaccess_pass}`
}

if (cachedHeaders && cachedHeaders.etag) {
headers[`If-None-Match`] = cachedHeaders.etag
}
Expand All @@ -53,7 +60,7 @@ module.exports = ({ url, store, cache, createNode }) =>
let statusCode
let responseHeaders
let responseError = false
const responseStream = got.stream(url, { headers })
const responseStream = got.stream(url, headers)
responseStream.pipe(fs.createWriteStream(tmpFilename))
responseStream.on(`downloadProgress`, pro => console.log(pro))

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-wordpress/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-source-wordpress",
"description": "Gatsby source plugin for building websites using the Wordpress CMS as a data source.",
"version": "2.0.44",
"version": "2.0.47",
"author": "Sebastien Fichot <fichot.sebastien@gmail.com>",
"bundleDependencies": false,
"dependencies": {
Expand All @@ -10,7 +10,7 @@
"bluebird": "^3.5.0",
"deep-map": "^1.5.0",
"deep-map-keys": "^1.2.0",
"gatsby-source-filesystem": "^1.5.11",
"gatsby-source-filesystem": "^1.5.14",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.4",
"qs": "^6.4.0",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-source-wordpress/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ exports.sourceNodes = async (
store,
cache,
createNode,
_auth,
})

// Search and replace Content Urls
Expand Down
9 changes: 8 additions & 1 deletion packages/gatsby-source-wordpress/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,13 @@ exports.mapEntitiesToMedia = entities => {
}

// Downloads media files and removes "sizes" data as useless in Gatsby context.
exports.downloadMediaFiles = async ({ entities, store, cache, createNode }) =>
exports.downloadMediaFiles = async ({
entities,
store,
cache,
createNode,
_auth,
}) =>
Promise.all(
entities.map(async e => {
let fileNode
Expand All @@ -401,6 +407,7 @@ exports.downloadMediaFiles = async ({ entities, store, cache, createNode }) =>
store,
cache,
createNode,
_auth,
})
} catch (e) {
// Ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby",
"description": "React.js Static Site Generator",
"version": "1.9.161",
"version": "1.9.163",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "./dist/bin/gatsby.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,33 +482,4 @@ describe(`GraphQL Input args`, () => {

expect(result).toMatchSnapshot()
})

it(`filters on linked fields`, async () => {
const { store, getNodes } = require(`../../redux`)
const linkedNodeType = new GraphQLObjectType({
name: `Bar`,
fields: {
id: { type: GraphQLString },
},
})
let types = [{ name: `Bar`, nodeObjectType: linkedNodeType }]

store.dispatch({
type: `CREATE_NODE`,
payload: { id: `baz`, internal: { type: `Bar` } },
})

let result = await queryResult(
[...getNodes(), { linked___NODE: `baz`, foo: `bar` }],
`
{
allNode(filter: { linked: { id: { eq: "baz" } } }) {
edges { node { linked { id } } }
}
}
`,
{ types }
)
expect(result.data.allNode.edges[0].node.linked.id).toEqual(`baz`)
})
})
9 changes: 2 additions & 7 deletions packages/gatsby/src/schema/infer-graphql-input-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const {
isEmptyObjectOrArray,
} = require(`./data-tree-utils`)

const { findLinkedNode } = require(`./infer-graphql-type`)

import type {
GraphQLInputFieldConfig,
GraphQLInputFieldConfigMap,
Expand Down Expand Up @@ -203,11 +201,8 @@ export function inferInputObjectStructureFromNodes({
// setting traversing up not try to automatically infer them.
if (isRoot && EXCLUDE_KEYS[key]) return

// Infer input arguments for linked nodes
if (_.includes(key, `___NODE`)) {
value = findLinkedNode(value)
;[key] = key.split(`___`)
}
// Input arguments on linked fields aren't currently supported
if (_.includes(key, `___NODE`)) return

let field = inferGraphQLInputFields({
nodes,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/infer-graphql-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function inferFromMapping(
}
}

export function findLinkedNode(value, linkedField, path) {
function findLinkedNode(value, linkedField, path) {
let linkedNode
// If the field doesn't link to the id, use that for searching.
if (linkedField) {
Expand Down
Loading

0 comments on commit b599aab

Please sign in to comment.