-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
179 lines (173 loc) · 5.63 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
176
177
178
179
const path = require(`path`)
const { githubApiQuery } = require("./github-api")
const config = require("./config/website")
const siteUrl = "https://chrisfrew.in"
module.exports = {
siteMetadata: {
siteUrl,
subtitle: config.subtitle,
subsubtitle: config.subsubtitle,
subsubsubtitle: config.subsubsubtitle,
title: config.siteTitle,
twitterHandle: config.twitterHandle,
description: config.siteDescription,
keywords: [
"Software Engineer",
"React",
"React Hooks",
".NET",
"TypeScript",
],
canonicalUrl: siteUrl,
image: config.siteLogo,
author: {
name: config.author,
minibio: config.minibio,
},
social: {
twitter: config.twitterHandle,
fbAppID: "",
},
},
plugins: [
{
resolve: `gatsby-source-github-api`,
options: {
url: "https://api.github.com/graphql", // default Github GraphQL v4 API endpoint
// token: required by the GitHub API
token: process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
// graphQLQuery: defaults to a search query
// comment out when working offline
graphQLQuery: githubApiQuery,
// variables: defaults to variables needed for a search query
variables: {
githubUsername: process.env.GITHUB_USERNAME,
repositoryName: "chrisfrew.in",
},
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: path.join(__dirname, `src`, `content`),
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: path.join(__dirname, `src`, `images`),
},
},
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
},
},
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: `UA-63301492-1`,
},
},
{
resolve: `gatsby-plugin-feed`,
options: {
feeds: [
getBlogFeed({
filePathRegex: `//content/blog//`,
blogUrl: "https://chrisfrew.in/blog",
output: "/rss.xml",
title: "Chris' Full Stack Blog RSS Feed",
}),
],
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: config.siteTitle,
short_name: config.siteTitleShort,
description: config.siteDescription,
start_url: config.pathPrefix,
lang: config.lang,
background_color: config.backgroundColor,
theme_color: config.themeColor,
display: "standalone",
icon: `src/images/maskable_icon.png`,
icon_options: {
purpose: `any maskable`,
},
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-image`,
`gatsby-plugin-sass`,
`gatsby-plugin-react-helmet`,
`gatsby-plugin-offline`,
`gatsby-plugin-sitemap`,
`gatsby-plugin-robots-txt`,
],
}
function getBlogFeed({ filePathRegex, blogUrl, ...overrides }) {
/**
* These RSS feeds can be quite expensive to generate. Limiting the number of
* posts and keeping each item's template lightweight (only using frontmatter,
* avoiding the html/excerpt fields) helps negate this.
*/
return {
serialize: ({ query: { allMdx } }) => {
const stripSlash = (slug) =>
slug.startsWith("/") ? slug.slice(1) : slug
return allMdx.edges.map((edge) => {
const url = `${siteUrl}/${stripSlash(edge.node.fields.slug)}`
return {
...edge.node.frontmatter,
url,
guid: url,
custom_elements: [
{
"content:encoded": `<div style="width: 100%; margin: 0 auto; max-width: 800px; padding: 40px 40px;">
<p>
There's a new blog post <em>"${edge.node.frontmatter.title}"</em> and you can <a href="${url}">read it online</a>.
<br>
${edge.node.fields.plainTextDescription}
<br>
You can also <a href="${config.subscriptionUrl}">subscribe</a> for weekly emails on my latest posts - if I publish anything that week!
</p>
</div>`,
},
],
}
})
},
query: `
{
allMdx(
limit: 25,
sort: { order: DESC, fields: [frontmatter___date] }
) {
edges {
node {
fields {
slug
}
frontmatter {
date
title
description
}
}
}
}
}
`,
...overrides,
}
}