Created
March 26, 2020 15:09
-
-
Save jpmarra/47188cf7774c316eb2748c1daa6b501d to your computer and use it in GitHub Desktop.
Gatsby Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path") | |
let contentfulConfig | |
try { | |
// Load the Contentful config from the .contentful.json | |
contentfulConfig = require("./.contentful") | |
const currentEnv = process.env.NODE_ENV | |
//TODO: Allow for preview API usage | |
// contentfulConfig = | |
// currentEnv === "production" | |
// ? contentfulConfig["production"] | |
// : contentfulConfig["development"] | |
contentfulConfig = contentfulConfig["production"] | |
console.log(`Using environment config: '${currentEnv}`) | |
} catch (_) {} | |
// Overwrite the Contentful config with environment variables if they exist | |
contentfulConfig = { | |
spaceId: process.env.CONTENTFUL_SPACE_ID || contentfulConfig.spaceId, | |
accessToken: | |
process.env.CONTENTFUL_DELIVERY_TOKEN || contentfulConfig.accessToken, | |
} | |
const { spaceId, accessToken } = contentfulConfig | |
if (!spaceId || !accessToken) { | |
throw new Error( | |
"Contentful spaceId and the delivery token need to be provided." | |
) | |
} | |
module.exports = { | |
siteMetadata: { | |
title: `Dye House`, | |
description: `Hotel & event space located in Olneyville`, | |
author: `@JP_Marra`, | |
}, | |
plugins: [ | |
`gatsby-plugin-react-helmet`, | |
{ | |
resolve: `gatsby-source-filesystem`, | |
options: { | |
name: `images`, | |
path: `${__dirname}/src/images`, | |
}, | |
}, | |
`gatsby-transformer-sharp`, | |
`gatsby-plugin-sharp`, | |
`gatsby-plugin-styled-components`, | |
{ | |
resolve: "gatsby-source-contentful", | |
options: contentfulConfig, | |
}, | |
{ | |
resolve: `gatsby-plugin-manifest`, | |
options: { | |
name: `Dye House`, | |
short_name: `Dye House`, | |
description: `Hotel & Event Space located in Olneyville Providence, RI`, | |
start_url: `/`, | |
background_color: `#222a37`, | |
theme_color: `#222a37`, | |
display: `minimal-ui`, | |
icon: `src/images/sheep-logo.png`, // This path is relative to the root of the site. | |
}, | |
}, | |
// this (optional) plugin enables Progressive Web App + Offline functionality | |
// To learn more, visit: https://gatsby.dev/offline | |
// `gatsby-plugin-offline`, | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment