/
gatsby-config.js
175 lines (170 loc) · 4.4 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* eslint-disable max-len */
require('dotenv').config({
path: '.env',
});
const contentfulConfig = {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
host: process.env.CONTENTFUL_HOST,
downloadLocal: true,
};
const { spaceId, accessToken } = contentfulConfig;
if (!spaceId || !accessToken) {
throw new Error(
'Contentful spaceId and the access token need to be provided.',
);
}
module.exports = {
siteMetadata: {
name: 'Andy Smith',
title: 'Andy.Writing',
location: 'London, UK',
description: 'Tech and Career blog by Andy Smith, Senior Software Engineer based in London, UK',
author: '@smittey',
siteUrl: 'https://www.smittey.co.uk/',
personalSiteUrl: 'https://www.andysmith.me/',
tagsPath: '/tags/',
},
plugins: [
{
resolve: 'gatsby-source-contentful',
options: contentfulConfig,
},
'gatsby-plugin-image',
'gatsby-plugin-react-helmet',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/assets/images`,
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
icon: 'src/assets/images/a-icon.png',
},
},
'gatsby-plugin-sass',
{
resolve: 'gatsby-plugin-google-analytics',
options: {
trackingId: 'UA-74354041-2',
exclude: ['.netlify.app'],
},
},
{
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingIds: [
'UA-74354041-2', // Google Analytics / GA
],
gtagConfig: {
anonymize_ip: true,
},
pluginConfig: {
head: false,
respectDNT: true,
exclude: [],
delayOnRouteUpdate: 0,
},
},
},
'gatsby-plugin-sharp',
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-images-contentful',
options: {
withWebp: true,
maxWidth: 1000,
},
},
{
resolve: 'gatsby-remark-prismjs',
options: {
classPrefix: 'language-',
},
},
],
},
},
{
resolve: 'gatsby-plugin-feed',
options: {
custom_namespaces: {
media: 'http://search.yahoo.com/mrss/',
},
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allContentfulBlogPost } }) => allContentfulBlogPost.edges.map((edge) => ({
title: edge.node.title,
date: edge.node.publishDate,
description: edge.node.previewText.previewText,
url: `${site.siteMetadata.siteUrl}/${edge.node.slug}`,
guid: `${site.siteMetadata.siteUrl}/${edge.node.slug}`,
custom_elements: [{
'media:content': {
_attr: {
url: `http:${edge.node.heroImage.localFile.childImageSharp.resize.src}`,
medium: 'image',
},
},
}],
})),
query: `{
site {
siteMetadata {
title
siteUrl
}
}
allContentfulBlogPost(sort: {fields: publishDate, order: DESC}) {
edges {
node {
title
publishDate
previewText {
previewText
}
heroImage {
localFile {
childImageSharp {
resize(width: 800, quality: 100) {
src
}
}
}
}
slug
}
}
}
}`,
output: '/feed.xml',
title: 'Andy.Writing Blog Post Feed',
},
],
},
},
],
};