-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.ts
265 lines (258 loc) · 7.18 KB
/
gatsby-config.ts
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/* eslint-disable max-lines */
import type { GatsbyConfig } from 'gatsby'
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
const config: GatsbyConfig = {
siteMetadata: {
title: 'jgjgill-blog',
description: 'frontend developer jgjgill blog',
author: 'jgjgill',
siteUrl: `https://jgjgill-blog.netlify.app/`,
},
flags: {
DEV_SSR: true,
},
// More easily incorporate content into your pages through automatic TypeScript type generation and better GraphQL IntelliSense.
// If you use VSCode you can also use the GraphQL plugin
// Learn more at: https://gatsby.dev/graphql-typegen
graphqlTypegen: true,
plugins: [
'gatsby-plugin-root-import',
'gatsby-plugin-image',
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
'gatsby-plugin-emotion',
{
resolve: 'gatsby-plugin-fusejs',
options: {
query: `
{
allMdx(
filter: { fields: { source: { eq: "contents" } } }
) {
nodes {
id
frontmatter {
title
date
slug
category
thumbnail_alt
thumbnail {
childImageSharp {
gatsbyImageData(transformOptions: { fit: FILL })
}
}
}
excerpt
body
}
}
}
`,
keys: ['frontmatter.title', 'excerpt'],
normalizer: ({ data }: any) =>
data.allMdx.nodes.map((node: any) => ({
id: node.id,
frontmatter: {
title: node.frontmatter.title,
slug: node.frontmatter.slug,
date: node.frontmatter.date,
category: node.frontmatter.category,
thumbnail_alt: node.frontmatter.thumbnail_alt,
thumbnail: node.frontmatter.thumbnail,
},
excerpt: node.excerpt,
body: node.body,
})),
},
},
{
resolve: 'gatsby-plugin-feed',
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}`,
feeds: [
{
serialize: ({ query: { site, allMdx } }: any) => {
return allMdx.nodes.map((node: any) => {
return Object.assign({}, node.frontmatter, {
title: node.frontmatter.title,
description: node.frontmatter.description ?? node.frontmatter.title,
date: new Date(node.frontmatter.date),
url: `${site.siteMetadata.siteUrl}/${node.frontmatter.type}/${node.frontmatter.slug}`,
guid: `${site.siteMetadata.siteUrl}/${node.frontmatter.type}/${node.frontmatter.slug}`,
custom_elements: [{ 'content:encoded': node.body }],
})
})
},
query: `
{
allMdx(sort: {frontmatter: {date: DESC}}) {
nodes {
frontmatter {
title
date
description
slug
type
}
body
}
}
}
`,
output: '/rss.xml',
title: "jgjgill's RSS Feed",
},
],
},
},
{
resolve: 'gatsby-plugin-react-svg',
options: { rule: { include: /\.inline\.svg$/ } },
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
host: 'https://jgjgill-blog.netlify.app/',
sitemap: 'https://jgjgill-blog.netlify.app/sitemap-index.xml',
policy: [{ userAgent: '*', allow: '/' }],
},
},
{
resolve: 'gatsby-plugin-sitemap',
options: {
query: `
{
site {
siteMetadata {
siteUrl
}
}
allMdx(sort: {frontmatter: {date: DESC}}) {
group(field: {frontmatter: {category: SELECT}}) {
fieldValue
}
nodes {
frontmatter {
slug
date
type
}
}
}
}
`,
resolveSiteUrl: () => `https://jgjgill-blog.netlify.app/`,
resolvePages: ({
allMdx: { nodes, group },
}: {
allMdx: {
nodes: {
frontmatter: { date: string; slug: string; type: 'post' | 'road' }
}[]
group: { fieldValue: string }[]
}
}) => {
const posts = nodes.map((node) => ({
path: `/${node.frontmatter.type}/${node.frontmatter.slug}`,
lastmod: node.frontmatter.date,
}))
const home = {
path: '/',
lastmod: posts[0].lastmod,
}
const about = {
path: '/about',
lastmod: posts[0].lastmod,
}
const categories = group.map((node) => ({
path: `/post/category/${node.fieldValue}`,
lastmod: posts[posts.length - 1].lastmod,
}))
return [...posts, ...categories, about, home]
},
serialize: ({ path, lastmod }: { path: string; lastmod: string }) => {
return {
url: path,
lastmod,
changefreq: 'daily',
priority: 0.7,
}
},
},
},
{
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingIds: [process.env.GA_TRACKING_ID],
pluginConfig: {
head: true,
},
},
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-autolink-headers',
},
// gatsby-remark-autolink-headers: gatsby-remark-prismjs 앞에 위치
// https://github.com/gatsbyjs/gatsby/issues/5764
{
resolve: 'gatsby-remark-prismjs',
},
],
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `jgjgill-blog`,
short_name: `jgjgill-blog`,
start_url: `/`,
background_color: `#f0abfc`,
theme_color: `#c471f5`,
display: `standalone`,
icon: 'src/images/icon.png',
cache_busting_mode: 'none',
icon_options: {
// For all the options available,
// please see the section "Additional Resources" below.
purpose: `any maskable`,
},
},
},
// gatsby-plugin-offline: manifest.webmanifest 캐시 생성을 위해 manifest 플러그인 이후에 위치
{
resolve: 'gatsby-plugin-offline',
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `contents`,
path: `${__dirname}/contents/`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `roads`,
path: `${__dirname}/roads/`,
},
},
],
}
export default config