From 584dfade6e847d1208688f90421b8a964d2c3762 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 22 Nov 2018 00:01:38 +0100 Subject: [PATCH] split gatsby-config.js --- gatsby-config.js | 45 ++------------------------------------------- gatsby/sources.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 43 deletions(-) create mode 100644 gatsby/sources.js diff --git a/gatsby-config.js b/gatsby-config.js index 81a603a6..44d2357f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -10,8 +10,8 @@ if (!process.env.GITHUB_TOKEN) { `) } -const path = require('path') const siteConfig = require('./config') +const sources = require('./gatsby/sources') // required for gatsby-plugin-meta-redirect require('regenerator-runtime/runtime') @@ -21,48 +21,7 @@ module.exports = { ...siteConfig }, plugins: [ - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'posts', - path: path.join(__dirname, 'content', 'posts') - } - }, - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'photos', - path: path.join(__dirname, 'content', 'photos') - } - }, - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'media', - path: path.join(__dirname, 'content', 'media') - } - }, - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'images', - path: path.join(__dirname, 'src', 'images') - } - }, - { - resolve: 'gatsby-source-graphql', - options: { - typeName: 'GitHub', - fieldName: 'github', - url: 'https://api.github.com/graphql', - headers: { - Authorization: `bearer ${process.env.GITHUB_TOKEN}` - }, - // Additional options to pass to node-fetch - fetchOptions: {}, - refetchInterval: 300 // 5 min. - } - }, + ...sources, 'gatsby-plugin-sharp', 'gatsby-transformer-sharp', { diff --git a/gatsby/sources.js b/gatsby/sources.js new file mode 100644 index 00000000..fd68c0f6 --- /dev/null +++ b/gatsby/sources.js @@ -0,0 +1,46 @@ +const path = require('path') + +module.exports = [ + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'posts', + path: path.join(__dirname, '..', 'content', 'posts') + } + }, + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'photos', + path: path.join(__dirname, '..', 'content', 'photos') + } + }, + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'media', + path: path.join(__dirname, '..', 'content', 'media') + } + }, + { + resolve: 'gatsby-source-filesystem', + options: { + name: 'images', + path: path.join(__dirname, '..', 'src', 'images') + } + }, + { + resolve: 'gatsby-source-graphql', + options: { + typeName: 'GitHub', + fieldName: 'github', + url: 'https://api.github.com/graphql', + headers: { + Authorization: `bearer ${process.env.GITHUB_TOKEN}` + }, + // Additional options to pass to node-fetch + fetchOptions: {}, + refetchInterval: 300 // 5 min. + } + } +]