-
Notifications
You must be signed in to change notification settings - Fork 4
/
gatsby-config.ts
153 lines (148 loc) · 4.05 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
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/
import dotenv from 'dotenv';
import { cleanEnv, str } from 'envalid';
import fs from 'node:fs';
import path from 'node:path';
import { GatsbyConfig } from 'gatsby';
import remarkGfm from 'remark-gfm';
import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
dotenv.config();
cleanEnv(process.env, { FIGMA_TOKEN: str() });
const cwd = process.cwd();
const config: GatsbyConfig = {
graphqlTypegen: true,
trailingSlash: 'never',
siteMetadata: {
title: 'Zendesk Garden',
siteUrl: 'https://garden.zendesk.com',
description: `Garden is the design system by Zendesk. It’s where we grow the components, standards, and tools that product designers use every day.`
},
plugins: [
/* analytics */
{
resolve: `gatsby-plugin-google-gtag`,
options: {
trackingIds: ['UA-970836-25']
}
},
/* generators */
'gatsby-plugin-netlify',
{
resolve: 'gatsby-plugin-sitemap',
options: {
// Trailing slash is required since Algolia docsearch does not crawl redirects
resolvePagePath: (page: { path: string }) =>
page.path.endsWith('/') ? page.path : `${page.path}/`
}
},
/* sources */
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'svg-icons',
path: `${cwd}/node_modules/@zendeskgarden/svg-icons/src`,
ignore: ['**/*.!(svg)']
},
__key: 'svg-icons'
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'icons',
path: path.join(cwd, 'src', 'icons')
},
__key: 'icons'
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'pages',
path: path.join(cwd, 'src', 'pages')
},
__key: 'pages'
},
/* sources - local/remote data */
'gatsby-source-garden-content',
'gatsby-source-garden-docgen',
/* bundling - file resolution */
{
resolve: 'gatsby-plugin-root-import',
// corresponds with tsconfig.json (compilerOptions.paths.*)
options: {
components: path.join(cwd, 'src', 'components'),
icons: path.join(cwd, 'src', 'icons')
}
},
/* bundling - transpilers */
'gatsby-plugin-styled-components',
{
resolve: 'gatsby-plugin-mdx',
options: {
mdxOptions: {
remarkPlugins: [remarkGfm]
},
gatsbyRemarkPlugins: [
'gatsby-remark-figma-assets',
'gatsby-remark-smartypants',
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 1000,
linkImagesToOriginal: false,
disableBgImageOnAlpha: true,
quality: 100,
wrapperStyle: `margin-bottom: ${DEFAULT_THEME.space.base * 5}px;`
}
},
{
// see: https://github.com/gatsbyjs/gatsby/issues/37049
resolve: 'gatsby-remark-autolink-headers',
options: {
offsetY: '0',
icon: fs
.readFileSync(`${cwd}/node_modules/@zendeskgarden/svg-icons/src/16/link-stroke.svg`)
.toString('utf-8')
.trim()
}
}
]
}
},
'gatsby-plugin-catch-links',
/* images */
'gatsby-plugin-image',
'gatsby-plugin-sharp',
'gatsby-transformer-garden-svg',
'gatsby-transformer-sharp',
{
resolve: 'gatsby-plugin-svgr',
options: {
svgo: true,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false
}
}
},
{
name: 'addAttributesToSVGElement',
params: {
attributes: [{ focusable: false }, { role: 'presentation' }]
}
}
]
}
}
}
]
};
export default config;