-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.ts
211 lines (206 loc) · 5.51 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
/*
Gatsby configuration file
-------------------------
*/
import dotenv from 'dotenv';
import type { GatsbyConfig } from 'gatsby';
import {
getSiteMetadata,
getSocialImageGenerationConfigDefaults,
getSocialImageGenerationConfigForType,
getTheme,
} from './src/common/config-manager';
import {
COVER_LETTER_PATH,
INDEX_PATH,
SOCIAL_IMAGES_PATH,
} from './src/common/constants';
import { getAbsoluteUrl } from './src/common/utils/urls';
import { SocialImageType, ThemeType } from './src/types/other';
import tailwindConfig from './tailwind.config';
const SITE_METADATA = getSiteMetadata();
const DARK_THEME = getTheme(ThemeType.Dark);
const OG_IMAGE_GENERATION_CONFIG = getSocialImageGenerationConfigForType(
SocialImageType.OpenGraph,
);
// Load environment variables from relevant .env file
dotenv.config({
path: `.env.${process.env.NODE_ENV}`,
});
const config: GatsbyConfig = {
siteMetadata: SITE_METADATA,
// Enable the new JSX transform so that we can use JSX without importing React
jsxRuntime: 'automatic',
trailingSlash: 'never',
graphqlTypegen: {
typesOutputPath: 'src/types/gatsby-types.d.ts',
},
plugins: [
'gatsby-plugin-fontawesome',
{
resolve: 'gatsby-plugin-component-to-image',
options: getSocialImageGenerationConfigDefaults(),
},
{
resolve: 'gatsby-plugin-postcss',
options: {
postCssPlugins: [
require('tailwindcss')(tailwindConfig),
require('autoprefixer'),
],
},
},
// This plugin needs to be listed after gatsby-plugin-postcss so that it can purge unused CSS
{
resolve: 'gatsby-plugin-purgecss',
options: {
tailwind: true,
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
purgeCSSOptions: {
safelist: [/where/, /data-theme/],
},
},
},
{
resolve: 'gatsby-plugin-sitemap',
options: {
// The sitemap index will be generated at /sitemap-index.xml
output: '/',
serialize: ({ path }: { path: string }) => ({
url: path,
changefreq: 'monthly',
}),
// Prevent temporary components rendered by gatsby-plugin-open-graph-images from being included in the sitemap
excludes: [`/${SOCIAL_IMAGES_PATH}/**/*`, COVER_LETTER_PATH],
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
// Link to the sitemap index generated above
sitemap: getAbsoluteUrl('sitemap-index.xml').toString(),
policy: [
{
userAgent: '*',
allow: '/',
},
],
},
},
{
resolve: 'gatsby-plugin-manifest',
options: {
name: SITE_METADATA.title,
description: SITE_METADATA.description,
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
short_name: SITE_METADATA.shortTitle,
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
start_url: INDEX_PATH,
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
background_color: DARK_THEME['base-100'],
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
theme_color: DARK_THEME.primary,
display: 'standalone',
icon: `${__dirname}/src/${SITE_METADATA.iconPath}`,
screenshots: [
{
src: 'images/og/index.webp',
sizes: `${OG_IMAGE_GENERATION_CONFIG.size.width}x${OG_IMAGE_GENERATION_CONFIG.size.height}`,
type: 'image/webp',
},
],
crossOrigin: 'use-credentials',
},
},
// This plugin needs to be listed after gatsby-plugin-manifest so that it can cache the generated manifest.webmanifest
'gatsby-plugin-offline',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'content',
path: `${__dirname}/src/content/`,
},
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-autolink-headers',
options: {
isIconAfterHeader: true,
},
},
],
},
},
{
resolve: 'gatsby-source-github-api',
options: {
token: process.env.GH_TOKEN,
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
graphQLQuery: `
query ($author: String = "", $repoLimit: Int = 0, $topicLimit: Int = 0, $languageLimit: Int = 0) {
user(login: $author) {
repositories(first: $repoLimit, orderBy: {field: STARGAZERS, direction: DESC}) {
nodes {
createdAt
description
forkCount
homepageUrl
isFork
languages(first: $languageLimit) {
nodes {
name
}
}
licenseInfo {
spdxId
name
url
}
name
openGraphImageUrl
owner {
login
}
readme: object(expression: "HEAD:README.md") {
... on Blob {
text
}
}
repositoryTopics(first: $topicLimit) {
nodes {
topic {
name
}
}
}
stargazerCount
updatedAt
url
usesCustomOpenGraphImage
}
}
}
}
`,
variables: {
repoLimit: 100,
topicLimit: 20,
languageLimit: 6,
author: SITE_METADATA.author.username.github,
},
},
},
{
resolve: 'gatsby-plugin-meta-redirect',
options: {
// We are using a fork of gatsby-plugin-meta-redirect that supports disabling trailing slashes
disableTrailingSlash: true,
},
},
],
};
// biome-ignore lint/style/noDefaultExport: Gatsby config must use default exports
export default config;