forked from prisma/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.ts
186 lines (180 loc) Β· 6.64 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
import type { GatsbyConfig } from 'gatsby'
import docsConfig from './config'
require('dotenv').config({
path: `.env`,
})
let plugins: any = [
'gatsby-plugin-image',
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
'gatsby-plugin-styled-components',
'gatsby-plugin-smoothscroll',
'gatsby-plugin-catch-links',
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: ['.mdx', '.md'],
gatsbyRemarkPlugins: [
'gatsby-remark-sectionize',
'gatsby-remark-normalize-paths',
{
resolve: `gatsby-remark-autolink-headers`,
options: {
icon: `<svg width="17" height="18" viewBox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.5 6.33337H15.5" stroke="#CBD5E0" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M1.5 11.6666H15.5" stroke="#CBD5E0" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M6.75 1L5 17" stroke="#CBD5E0" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M12 1L10.25 17" stroke="#CBD5E0" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>`,
className: `title-link`,
enableCustomId: true,
},
},
{
resolve: `gatsby-remark-image-custom`,
options: {
disableBgImageOnAlpha: true,
quality: 100,
},
},
{
resolve: 'gatsby-remark-to-absoluteurl',
options: {
redirects: docsConfig.redirects,
},
},
{
resolve: 'gatsby-remark-check-links-numberless',
options: {
// Do not surface links to these pages as broken:
exceptions: [
'/guides/upgrade-guides/upgrade-from-prisma-1/schema-incompatibilities-postgresql',
'/guides/upgrade-guides/upgrade-from-prisma-1/upgrading-the-prisma-layer-postgresql',
'/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql',
'/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql',
'/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-planetscale',
'/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-planetscale',
'/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-planetscale',
'/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-typescript-planetscale',
'/getting-started/setup-prisma/add-to-existing-project/mongodb-typescript-mongodb',
'/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb',
'/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-cockroachdb',
'/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-cockroachdb',
'/getting-started/setup-prisma/add-to-existing-project/relational-databases/baseline-your-database-typescript-cockroachdb',
],
},
},
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
destinationDir: 'static',
},
},
],
},
},
{
resolve: 'gatsby-plugin-google-tagmanager',
options: {
id: 'GTM-KCGZPWB',
includeInDevelopment: false,
defaultDataLayer: { website: 'docs' },
},
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
entryLimit: 5000,
excludes: [
// Remove these from sitemap for SEO purposes as they're redirected
`/getting-started/quickstart`,
`/getting-started/setup-prisma/add-to-existing-project`,
`/getting-started/setup-prisma/start-from-scratch-prisma-migrate`,
`/getting-started/setup-prisma/start-from-scratch-sql`,
],
resolvePagePath: (page: any) => {
return page.path.replace(/\/$/, '')
},
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
policy: [
{
userAgent: '*',
disallow: ['/', '/*?query=*', '/*?page=*', '/*&query=*', '/*&page=*'],
},
],
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images/`,
},
__key: 'images',
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: `docs`,
path: `${__dirname}/content`,
},
__key: 'pages',
},
'gatsby-plugin-meta-redirect',
'gatsby-plugin-page-list',
'gatsby-plugin-lost-pixel',
]
if (process.env.INDEX_ALGOLIA === 'true') {
if (process.env.GATSBY_ALGOLIA_APP_ID) {
// only set this up when we actually need it
const algoliaPlugin = {
resolve: 'gatsby-algolia-indexer',
options: {
appId: process.env.GATSBY_ALGOLIA_APP_ID,
adminKey: process.env.GATSBY_ALGOLIA_ADMIN_API_KEY,
searchKey: process.env.GATSBY_ALGOLIA_SEARCH_KEY,
indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME,
types: [`Mdx`],
},
__key: 'search',
}
plugins.push(algoliaPlugin)
console.log(
'INDEX_ALGOLIA is `true`, and GATSBY_ALGOLIA_APP_ID is set, so pushing algoliaPlugin to list of plugins to trigger search indexing.'
)
} else {
console.warn('INDEX_ALGOLIA === true, but GATSBY_ALGOLIA_APP_ID is undefined.')
}
} else {
console.log('INDEX_ALGOLIA not `true`, not pushing algoliaPlugin to skip any search indexing.')
}
const config: GatsbyConfig = {
pathPrefix: process.env.ADD_PREFIX === 'true' ? docsConfig.gatsby.pathPrefix : '/',
// trailingSlash: 'never',
siteMetadata: {
pathPrefix: docsConfig.gatsby.pathPrefix,
title: docsConfig.siteMetadata.title,
titlePrefix: docsConfig.gatsby.titlePrefix,
titleSuffix: docsConfig.gatsby.titleSuffix,
description: docsConfig.siteMetadata.description,
keywords: docsConfig.siteMetadata.keywords,
twitter: docsConfig.siteMetadata.twitter,
og: docsConfig.siteMetadata.og,
header: docsConfig.header,
siteUrl: docsConfig.gatsby.siteUrl,
footer: docsConfig.footer,
docsLocation: docsConfig.siteMetadata.docsLocation,
redirects: docsConfig.redirects,
homepage: docsConfig.homepage,
},
// 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,
}
export default config