Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ public
node_modules
*DS_Store
*.env
.env.development
.env.production
.netlify/

.idea/
74 changes: 51 additions & 23 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
require("dotenv").config();
const queries = require("./src/utils/algolia");
const config = require("./config");
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});
// keep dotenv at the top of this file

const queries = require('./src/utils/algolia');

const config = require('./config');

const sharp = require('sharp');

// disable sharp cacheing to stop segmentation faults on netlify
sharp.cache(false);
sharp.simd(false);

const GATSBY_SHOW_DOCS = process.env.GATSBY_SHOW_DOCS;

const GATSBY_SETTINGS_FILE = process.env.GATSBY_SETTINGS_FILE;

const GATSBY_ENV = process.env.GATSBY_ENV;

console.log({ GATSBY_ENV, GATSBY_SETTINGS_FILE, GATSBY_SHOW_DOCS });

const plugins = [
'gatsby-plugin-sitemap',
'gatsby-plugin-sharp',
{
resolve: `gatsby-plugin-layout`,
options: {
component: require.resolve(`./src/templates/docs.js`)
}
component: require.resolve(`./src/templates/docs.js`),
},
},
'gatsby-plugin-emotion',
'gatsby-plugin-react-helmet',
{
resolve: "gatsby-source-filesystem",
resolve: 'gatsby-source-filesystem',
options: {
name: "docs",
path: `${__dirname}/content/`
}
name: 'docs',
path: `${__dirname}/content/`,
},
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-images",
resolve: 'gatsby-remark-images',
options: {
maxWidth: 1035,
sizeByPixelDensity: true
}
sizeByPixelDensity: true,
},
},
{
resolve: 'gatsby-remark-copy-linked-files'
}
resolve: 'gatsby-remark-copy-linked-files',
},
],
extensions: [".mdx", ".md"]
}
extensions: ['.mdx', '.md'],
},
},
{
resolve: `gatsby-plugin-gtag`,
Expand All @@ -50,22 +70,27 @@ const plugins = [
},
];
// check and add algolia
if (config.header.search && config.header.search.enabled && config.header.search.algoliaAppId && config.header.search.algoliaAdminKey) {
if (
config.header.search &&
config.header.search.enabled &&
config.header.search.algoliaAppId &&
config.header.search.algoliaAdminKey
) {
plugins.push({
resolve: `gatsby-plugin-algolia`,
options: {
appId: config.header.search.algoliaAppId, // algolia application id
apiKey: config.header.search.algoliaAdminKey, // algolia admin key to index
queries,
chunkSize: 10000, // default: 1000
}}
)
},
});
}
// check and add pwa functionality
if (config.pwa && config.pwa.enabled && config.pwa.manifest) {
plugins.push({
resolve: `gatsby-plugin-manifest`,
options: {...config.pwa.manifest},
resolve: `gatsby-plugin-manifest`,
options: { ...config.pwa.manifest },
});
plugins.push({
resolve: 'gatsby-plugin-offline',
Expand All @@ -90,13 +115,16 @@ module.exports = {
docsLocation: config.siteMetadata.docsLocation,
ogImage: config.siteMetadata.ogImage,
favicon: config.siteMetadata.favicon,
logo: { link: config.header.logoLink ? config.header.logoLink : '/', image: config.header.logo }, // backwards compatible
logo: {
link: config.header.logoLink ? config.header.logoLink : '/',
image: config.header.logo,
}, // backwards compatible
headerTitle: config.header.title,
githubUrl: config.header.githubUrl,
helpUrl: config.header.helpUrl,
tweetText: config.header.tweetText,
headerLinks: config.header.links,
siteUrl: config.gatsby.siteUrl,
},
plugins: plugins
plugins: plugins,
};
5 changes: 4 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const componentWithMDXScope = require('gatsby-plugin-mdx/component-with-mdx-scope');
// uncomment to use process.env.* in node
// require("dotenv").config({
// path: `.env.${process.env.NODE_ENV}`,
// })

const path = require('path');

Expand Down
22 changes: 22 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
[build]
publish = "public"
command = "npm run build"

# contexts:
# - production: master branch
# - deploy preview: PRs/merges on master branch
# - branch deploys: all other deploys

# use strings to match node .env

[context.production.environment]
GATSBY_ENV = "production"
GATSBY_SETTINGS_FILE = "netlify"
GATSBY_SHOW_DOCS = "false"

[context.deploy-preview.environment]
GATSBY_ENV = "deploy-preview"
GATSBY_SETTINGS_FILE = "netlify"
GATSBY_SHOW_DOCS = "false"

[context.branch-deploy.environment]
GATSBY_ENV = "branch-deploy"
GATSBY_SETTINGS_FILE = "netlify"
GATSBY_SHOW_DOCS = "true"
Loading