-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgatsby-config.js
155 lines (149 loc) · 5.2 KB
/
gatsby-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
require("dotenv").config();
const queries = require("./src/utils/algolia");
const config = require("./config");
const plugins = [
'gatsby-plugin-sitemap',
"gatsby-plugin-anchor-links",
'gatsby-plugin-sharp',
{
resolve: `gatsby-plugin-layout`,
options: {
component: require.resolve(`./src/templates/docs.js`)
}
},
'gatsby-plugin-emotion',
'gatsby-plugin-remove-trailing-slashes',
'gatsby-plugin-react-helmet',
{
resolve: "gatsby-source-filesystem",
options: {
name: "docs",
path: `${__dirname}/content/`,
}
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 1035,
sizeByPixelDensity: true
}
},
{
resolve: 'gatsby-remark-copy-linked-files'
}
],
extensions: [".mdx", ".md"],
}
},
{
resolve: "example-loader",
options: {
name: "examples",
path: `${__dirname}/examples/`
}
},
{
resolve: 'gatsby-plugin-zopfli',
options: {
extensions: ['css', 'html', 'js', 'svg'],
verbose: true
}
},
{
resolve: `gatsby-plugin-segment-js`,
options: {
// your segment write key for your production environment
// when process.env.NODE_ENV === 'production'
// required; non-empty string
prodKey: config.segment.productionWriteKey,
// boolean (defaults to false) on whether you want
// to include analytics.page() automatically
// if false, see below on how to track pageviews manually
trackPage: true,
// number (defaults to 50); time to wait after a route update before it should
// track the page change, to implement this, make sure your `trackPage` property is set to `true`
trackPageDelay: 50,
// boolean (defaults to false); whether to delay load Segment
// ADVANCED FEATURE: only use if you leverage client-side routing (ie, Gatsby <Link>)
// This feature will force Segment to load _after_ either a page routing change
// or user scroll, whichever comes first. This delay time is controlled by
// `delayLoadTime` setting. This feature is used to help improve your website's
// TTI (for SEO, UX, etc). See links below for more info.
// NOTE: But if you are using server-side routing and enable this feature,
// Segment will never load (because although client-side routing does not do
// a full page refresh, server-side routing does, thereby preventing Segment
// from ever loading).
// See here for more context:
// GIF: https://github.com/benjaminhoffman/gatsby-plugin-segment-js/pull/19#issuecomment-559569483
// TTI: https://github.com/GoogleChrome/lighthouse/blob/master/docs/scoring.md#performance
// Problem/solution: https://marketingexamples.com/seo/performance
delayLoad: false,
// number (default to 1000); time to wait after scroll or route change
// To be used when `delayLoad` is set to `true`
delayLoadTime: 1000,
// Whether to completely skip calling `analytics.load()`.
// ADVANCED FEATURE: only use if you are calling `analytics.load()` manually
// elsewhere in your code or are using a library
// like: https://github.com/segmentio/consent-manager that will call it for you.
// Useful for only loading the tracking script once a user has opted in to being tracked, for example.
manualLoad: false,
}
},
{
resolve: "gatsby-plugin-google-tagmanager",
options: {
id: process.env.GOOGLE_TAG_MANAGER_ID,
includeInDevelopment: false,
defaultDataLayer: { platform: "gatsby" },
},
},
];
// check and add algolia
if (config.header.search && config.header.search.enabled && config.header.search.algoliaAppId && config.header.search.algoliaAdminKey) {
plugins.push({
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.GATSBY_ALGOLIA_APP_ID, // algolia application id
apiKey: process.env.GATSBY_ALGOLIA_ADMIN_KEY, // 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},
});
plugins.push({
resolve: 'gatsby-plugin-offline',
options: {
appendScript: require.resolve(`./src/custom-sw-code.js`),
},
});
} else {
plugins.push('gatsby-plugin-remove-serviceworker');
}
module.exports = {
pathPrefix: config.gatsby.pathPrefix,
siteMetadata: {
title: config.siteMetadata.title,
description: config.siteMetadata.description,
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
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
};