-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
167 lines (165 loc) · 4.9 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
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});
module.exports = {
siteMetadata: {
siteUrl: process.env.SITE_URL,
title: 'Jimmy Hooker',
description: "Jimmy Hooker's inane ramblings",
author: 'Jimmy Hooker',
keywords: ['Jimmy Hooker', 'San Francisco', 'Software'],
image: '/opengraph-default.png',
twitterUsername: '@hisnameisjimmy',
},
plugins: [
`gatsby-plugin-postcss`,
`gatsby-plugin-twitter`,
'gatsby-plugin-image',
{
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingIds: ['G-4HPC5TT803'],
},
},
'gatsby-plugin-react-helmet',
'gatsby-plugin-sitemap',
{
resolve: 'gatsby-plugin-feed',
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMdx } }) => {
return allMdx.edges.map((edge) => {
const featuredImageUrl = edge.node.frontmatter.featured_image
? site.siteMetadata.siteUrl +
edge.node.frontmatter.featured_image.publicURL
: null;
return {
title: edge.node.frontmatter.title,
description: edge.node.excerpt,
date: edge.node.frontmatter.date,
url: site.siteMetadata.siteUrl + '/blog/' + edge.node.slug,
guid: site.siteMetadata.siteUrl + '/blog/' + edge.node.slug,
enclosure: featuredImageUrl
? { url: featuredImageUrl }
: undefined,
custom_elements: [
{
'content:encoded': edge.node.html
// Fix image paths to be absolute:
.replace(
/<img ([^>]*?)src="\/static\//g,
`<img $1src="${site.siteMetadata.siteUrl}/static/`,
)
// Remove srcSet attributes explicitly:
.replace(/srcSet="[^"]*"/g, '')
// Remove sizes attributes explicitly:
.replace(/sizes="[^"]*"/g, '')
// Cleanup: Remove unnecessary spaces between attributes:
.replace(
/<img (\s+[^>]+)>/g,
(match, p1) =>
`<img ${p1.trim().replace(/\s{2,}/g, ' ')}>`,
)
// Optional: Standardize width for all images in the RSS:
.replace(/<img /g, '<img width="1200" ')
.trim(),
},
],
};
});
},
query: `
{
allMdx(sort: {fields: frontmatter___date, order: DESC}, filter: {frontmatter: {post_type: {eq: "blog"}}}) {
edges {
node {
excerpt
body
slug
html
frontmatter {
title
date
featured_image {
publicURL
}
}
}
}
}
}
`,
output: '/rss.xml',
title: "Jimmy Hooker's RSS Feed",
image_url: process.env.SITE_URL + '/icon.png',
},
],
},
},
'gatsby-plugin-image',
{
resolve: 'gatsby-plugin-manifest',
options: {
icon: 'src/images/icon.png',
},
},
`gatsby-remark-images`,
`gatsby-remark-images-medium-zoom`,
{
resolve: `gatsby-plugin-mdx`,
options: {
plugins: [`gatsby-remark-images`, `gatsby-remark-images-medium-zoom`],
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
linkImagesToOriginal: false,
},
},
{
resolve: `gatsby-remark-images-medium-zoom`,
options: {},
},
],
},
},
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: './src/images/',
},
__key: 'images',
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: `blog`,
path: `${__dirname}/blog/`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: `portfolio`,
path: `${__dirname}/portfolio/`,
},
},
],
};