Skip to content

Commit f9c342a

Browse files
authored
wip flags (#1)
1 parent a8b2e4e commit f9c342a

File tree

7 files changed

+24934
-27
lines changed

7 files changed

+24934
-27
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ public
33
node_modules
44
*DS_Store
55
*.env
6+
.env.development
7+
.env.production
8+
.netlify/
69

710
.idea/

gatsby-config.js

+51-23
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,61 @@
1-
require("dotenv").config();
2-
const queries = require("./src/utils/algolia");
3-
const config = require("./config");
1+
require('dotenv').config({
2+
path: `.env.${process.env.NODE_ENV}`,
3+
});
4+
// keep dotenv at the top of this file
5+
6+
const queries = require('./src/utils/algolia');
7+
8+
const config = require('./config');
9+
10+
const sharp = require('sharp');
11+
12+
// disable sharp cacheing to stop segmentation faults on netlify
13+
sharp.cache(false);
14+
sharp.simd(false);
15+
16+
const GATSBY_SHOW_DOCS = process.env.GATSBY_SHOW_DOCS;
17+
18+
const GATSBY_SETTINGS_FILE = process.env.GATSBY_SETTINGS_FILE;
19+
20+
const GATSBY_ENV = process.env.GATSBY_ENV;
21+
22+
console.log({ GATSBY_ENV, GATSBY_SETTINGS_FILE, GATSBY_SHOW_DOCS });
23+
424
const plugins = [
525
'gatsby-plugin-sitemap',
626
'gatsby-plugin-sharp',
727
{
828
resolve: `gatsby-plugin-layout`,
929
options: {
10-
component: require.resolve(`./src/templates/docs.js`)
11-
}
30+
component: require.resolve(`./src/templates/docs.js`),
31+
},
1232
},
1333
'gatsby-plugin-emotion',
1434
'gatsby-plugin-react-helmet',
1535
{
16-
resolve: "gatsby-source-filesystem",
36+
resolve: 'gatsby-source-filesystem',
1737
options: {
18-
name: "docs",
19-
path: `${__dirname}/content/`
20-
}
38+
name: 'docs',
39+
path: `${__dirname}/content/`,
40+
},
2141
},
2242
{
2343
resolve: 'gatsby-plugin-mdx',
2444
options: {
2545
gatsbyRemarkPlugins: [
2646
{
27-
resolve: "gatsby-remark-images",
47+
resolve: 'gatsby-remark-images',
2848
options: {
2949
maxWidth: 1035,
30-
sizeByPixelDensity: true
31-
}
50+
sizeByPixelDensity: true,
51+
},
3252
},
3353
{
34-
resolve: 'gatsby-remark-copy-linked-files'
35-
}
54+
resolve: 'gatsby-remark-copy-linked-files',
55+
},
3656
],
37-
extensions: [".mdx", ".md"]
38-
}
57+
extensions: ['.mdx', '.md'],
58+
},
3959
},
4060
{
4161
resolve: `gatsby-plugin-gtag`,
@@ -50,22 +70,27 @@ const plugins = [
5070
},
5171
];
5272
// check and add algolia
53-
if (config.header.search && config.header.search.enabled && config.header.search.algoliaAppId && config.header.search.algoliaAdminKey) {
73+
if (
74+
config.header.search &&
75+
config.header.search.enabled &&
76+
config.header.search.algoliaAppId &&
77+
config.header.search.algoliaAdminKey
78+
) {
5479
plugins.push({
5580
resolve: `gatsby-plugin-algolia`,
5681
options: {
5782
appId: config.header.search.algoliaAppId, // algolia application id
5883
apiKey: config.header.search.algoliaAdminKey, // algolia admin key to index
5984
queries,
6085
chunkSize: 10000, // default: 1000
61-
}}
62-
)
86+
},
87+
});
6388
}
6489
// check and add pwa functionality
6590
if (config.pwa && config.pwa.enabled && config.pwa.manifest) {
6691
plugins.push({
67-
resolve: `gatsby-plugin-manifest`,
68-
options: {...config.pwa.manifest},
92+
resolve: `gatsby-plugin-manifest`,
93+
options: { ...config.pwa.manifest },
6994
});
7095
plugins.push({
7196
resolve: 'gatsby-plugin-offline',
@@ -90,13 +115,16 @@ module.exports = {
90115
docsLocation: config.siteMetadata.docsLocation,
91116
ogImage: config.siteMetadata.ogImage,
92117
favicon: config.siteMetadata.favicon,
93-
logo: { link: config.header.logoLink ? config.header.logoLink : '/', image: config.header.logo }, // backwards compatible
118+
logo: {
119+
link: config.header.logoLink ? config.header.logoLink : '/',
120+
image: config.header.logo,
121+
}, // backwards compatible
94122
headerTitle: config.header.title,
95123
githubUrl: config.header.githubUrl,
96124
helpUrl: config.header.helpUrl,
97125
tweetText: config.header.tweetText,
98126
headerLinks: config.header.links,
99127
siteUrl: config.gatsby.siteUrl,
100128
},
101-
plugins: plugins
129+
plugins: plugins,
102130
};

gatsby-node.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const componentWithMDXScope = require('gatsby-plugin-mdx/component-with-mdx-scope');
1+
// uncomment to use process.env.* in node
2+
// require("dotenv").config({
3+
// path: `.env.${process.env.NODE_ENV}`,
4+
// })
25

36
const path = require('path');
47

netlify.toml

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
[build]
22
publish = "public"
33
command = "npm run build"
4+
5+
# contexts:
6+
# - production: master branch
7+
# - deploy preview: PRs/merges on master branch
8+
# - branch deploys: all other deploys
9+
10+
# use strings to match node .env
11+
12+
[context.production.environment]
13+
GATSBY_ENV = "production"
14+
GATSBY_SETTINGS_FILE = "netlify"
15+
GATSBY_SHOW_DOCS = "false"
16+
17+
[context.deploy-preview.environment]
18+
GATSBY_ENV = "deploy-preview"
19+
GATSBY_SETTINGS_FILE = "netlify"
20+
GATSBY_SHOW_DOCS = "false"
21+
22+
[context.branch-deploy.environment]
23+
GATSBY_ENV = "branch-deploy"
24+
GATSBY_SETTINGS_FILE = "netlify"
25+
GATSBY_SHOW_DOCS = "true"

0 commit comments

Comments
 (0)