-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
86 lines (72 loc) · 2.85 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
let dotenv = require('dotenv')
const _ = require(`lodash`)
dotenv.config()
// console.log(process.env.WORDPRESS_HOST, process.env.PROTOCOL);
module.exports = {
siteMetadata: {
title: `Tobie Marier Robitaille`,
siteUrl: `${process.env.SITE_URL}`,
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sitemap`,
{
resolve: `gatsby-plugin-sass`
},
{
resolve: `gatsby-source-wordpress`,
options: {
baseUrl: `${process.env.WORDPRESS_HOST}`,
protocol: `${process.env.PROTOCOL}`,
useACF: true,
// Set verboseOutput to true to display a verbose output on `npm run develop` or `npm run build`
// It can help you debug specific API Endpoints problems.
verboseOutput: true,
perPage: 100,
auth: {
// If auth.user and auth.pass are filled, then the source plugin will be allowed
// to access endpoints that are protected with .htaccess.
htaccess_user: `${process.env.WORDPRESS_USER}`,
htaccess_pass: `${process.env.WORDPRESS_PASS}`,
htaccess_sendImmediately: false
},
// Search and Replace Urls across WordPress content.
// searchAndReplaceContentUrls: {
// sourceUrl: "https://source-url.com",
// replacementUrl: "https://replacement-url.com",
// },
// Set how many simultaneous requests are sent at once.
concurrentRequests: 10,
// Exclude specific routes using glob parameters
// See: https://github.com/isaacs/minimatch
// Example: `["/*/*/comments", "/yoast/**"]` will exclude routes ending in `comments` and
// all routes that begin with `yoast` from fetch.
excludedRoutes: [`/*/*/comments`, `/yoast/**`, `/wordfence/**`, `/siteground-optimizer/**`, `/redirection/**`, `/themes/**`, `/block-directory/**`],
// use a custom normalizer which is applied after the built-in ones.
normalizer: function({ entities }) {
// console.log('entities:', entities)
return entities.map((entity) => {
//
// Fix bug with ACF file fields
//
if (typeof entity.__type !== `undefined` && entity.acf) {
var keys = Object.keys(entity.acf);
_.forEach(keys, (key) => {
let has___NODE = key.match(/___NODE/)
if (has___NODE) {
// find node
let node = entities.filter(e => e.id === entity.acf[key])
// if a node was found, attach to entry.acf object
// slice '___NODE' from the original key name as the new key name
if(node[0]) entity.acf[key.slice(0, has___NODE.index)] = node[0]
}
})
}
return entity
})
return entities
}
},
}
]
}