-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
161 lines (155 loc) · 4.62 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
156
157
158
159
160
161
const DRUPAL_URL = process.env.DRUPAL_URL || 'https://cms.lib.umich.edu/';
const DRUPAL_CONCURRENT_FILE_REQUESTS = parseInt(process.env.DRUPAL_CONCURRENT_FILE_REQUESTS) || 20;
const DRUPAL_REQUEST_TIMEOUT = parseInt(process.env.DRUPAL_REQUEST_TIMEOUT) || 6000000;
console.log('[gatsby-config] ENV VARs');
console.log(`DRUPAL_URL='${DRUPAL_URL}'`);
console.log(`DRUPAL_CONCURRENT_FILE_REQUESTS=${DRUPAL_CONCURRENT_FILE_REQUESTS}`);
console.log(`DRUPAL_REQUEST_TIMEOUT=${DRUPAL_REQUEST_TIMEOUT}`);
const siteMetadata = {
title: 'University of Michigan Library',
siteUrl: 'https://www.lib.umich.edu',
};
module.exports = {
flags: {
DEV_SSR: false, // Watches gatsby-ssr.js while developing
},
siteMetadata,
plugins: [
'gatsby-plugin-netlify', // Netlify recommends this plugin on top of Essential Gatsby (Version 2): https://github.com/netlify/netlify-plugin-gatsby#install-the-gatsby-plugin
'gatsby-plugin-meta-redirect',
'gatsby-plugin-remove-fingerprints', // Why? Read why Netlify recommends: https://github.com/gatsbyjs/gatsby/issues/11961#issuecomment-492893594
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images/`,
},
},
'gatsby-plugin-sitemap',
{
resolve: 'gatsby-plugin-robots-txt',
options: {
host: siteMetadata.siteUrl,
sitemap: siteMetadata.siteUrl + '/sitemap-index.xml',
resolveEnv: () => {
/**
*
* Assume development env for robots.txt unless explicity
* set to production with ROBOTSTXT_MODE env var.
*/
let mode = 'development';
/**
* Only is the mode in production when Netlify is deploying from
* the sites production branch and ROBOTSTXT_MODE is set to production.
*/
if (process.env.ROBOTSTXT_MODE === 'production') {
mode = 'production';
}
console.log(`[gatsby-plugin-robots-txt] is in ${mode} mode.`);
return mode;
},
env: {
production: {
policy: [
{
userAgent: '*',
allow: '/',
},
],
},
development: {
policy: [
{
userAgent: '*',
disallow: ['/'],
host: null,
sitemap: null,
},
],
},
},
},
},
'gatsby-plugin-image',
{
resolve: 'gatsby-plugin-sharp',
options: {
stripMetadata: true,
defaultQuality: 75,
},
},
'gatsby-transformer-sharp',
{
resolve: 'gatsby-source-drupal',
options: {
baseUrl: DRUPAL_URL,
apiBase: 'jsonapi',
concurrentFileRequests: DRUPAL_CONCURRENT_FILE_REQUESTS,
filters: {
/*
Filter out temporary files. This will help to avoid Gatsby
throwing an error when a 404 is returned from a file
that does not exist.
*/
'file--file': 'filter[status][value]=1',
},
requestTimeoutMS: DRUPAL_REQUEST_TIMEOUT
},
},
{
resolve: 'gatsby-source-umich-lib',
options: {
baseUrl: DRUPAL_URL,
},
},
'gatsby-plugin-remove-serviceworker',
'gatsby-plugin-emotion',
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'University of Michigan Library',
short_name: 'U-M Library',
start_url: '/',
background_color: '#00274C',
theme_color: '#FFCB05',
display: 'minimal-ui',
icon: 'src/images/icon.png', // This path is relative to the root of the site.
},
},
{
resolve: 'gatsby-plugin-lunr',
options: {
languages: [{ name: 'en' }],
fields: [
{
name: 'title',
store: true,
attributes: { boost: 9 },
},
{
name: 'summary',
store: true,
attributes: { boost: 3 },
},
{
name: 'keywords',
store: true,
},
{
name: 'uniqname',
store: true,
},
],
resolvers: {
SitePage: {
uniqname: (node) => (node.context ? node.context.uniqname : null),
title: (node) => (node.context ? node.context.title : null),
summary: (node) => (node.context ? node.context.summary : null),
keywords: (node) => (node.context ? node.context.keywords : null),
},
},
},
},
],
trailingSlash: 'never',
};