-
Notifications
You must be signed in to change notification settings - Fork 90
/
gatsby-config.js
170 lines (157 loc) · 4.34 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
const docsConfig = require("./docs-config.js")
const isProduction = process.env.NODE_ENV === "production"
const getProduct = (name) => {
const repo = "@cloudflare/cloudflare-brand-assets"
const dir = "resources/product-icons/"
return `./node_modules/${repo}/${dir}/${name}.js`
}
const products = [
"1.1.1.1",
"access",
"analytics",
"api",
"automatic-platform-optimization",
"argo-tunnel",
"bots",
"byoip",
"cache",
"client-ip-geolocation",
"cloudflare-for-teams",
"cloudflare-one",
"distributed-web",
"docs-engine",
"events",
"firewall",
"fundamentals",
"gateway",
"http3",
"images",
"load-balancing",
"logs",
"magic-transit",
"magic-wan",
"mobile-sdk",
"network-interconnect",
"page-shield",
"railgun",
"randomness-beacon",
"registrar",
"rules",
"spectrum",
"ssl",
"stream",
"tenant",
"terraform",
"time-services",
"waf",
"waiting-room",
"warp-client",
"workers",
]
// TODO: Delete later
const productIcons = {}
products.forEach(name => {
productIcons[name] = require(getProduct(name)).pathD
})
// TODO: Delete later on, This is to support some cases when the pathD is directly added in the docs-config manually in the product instead of getting the icon from the cloudflare-brand-assets repo
if (docsConfig.productIconKey && !docsConfig.productLogoPathD) {
docsConfig.productLogoPathD = productIcons.productIconKey ? productIcons[docsConfig.productIconKey] : ''
}
const siteMetadata = docsConfig.siteMetadata
siteMetadata.cloudflareDocs = {}
Object.keys(docsConfig).forEach(prop => {
if (prop === "siteMetadata") return
siteMetadata.cloudflareDocs[prop] = docsConfig[prop]
})
// TODO: Delete later on
siteMetadata.cloudflareDocs.productIcons = productIcons
// We exposed friendlier siteMetadata.url to Docs consumers but
// gatsby-plugin-sitemap requires `siteUrl` https://git.io/JUUxW
siteMetadata.siteUrl = siteMetadata.url
delete siteMetadata.url
module.exports = {
// Deploy production site to the docs config pathPrefix
// but keep local development done at the root due to:
// https://github.com/gatsbyjs/gatsby/issues/16040
pathPrefix: isProduction ? docsConfig.pathPrefix : "",
siteMetadata: siteMetadata,
plugins: [
"gatsby-plugin-eslint",
"gatsby-plugin-no-sourcemaps",
"gatsby-plugin-react-helmet",
"gatsby-transformer-sharp",
"gatsby-plugin-sharp",
"gatsby-plugin-remove-trailing-slashes",
// Sets page.updatedAt to the author time of last commit (https://git.io/JfPCj)
"saber-plugin-git-modification-time",
// Custom sitemap configuration that fixes prefix issues
{
resolve: `gatsby-plugin-sitemap`,
options: {
resolveSiteUrl: () => new URL(siteMetadata.siteUrl).origin,
},
},
// Prevent nav from (un)mounting on page navigations (https://git.io/JfOKn)
{
resolve: "gatsby-plugin-layout",
options: {
component: require.resolve("./src/components/docs-page.js")
}
},
{
resolve: "gatsby-source-filesystem",
options: {
path: `${__dirname}/src/content/`
}
},
{
resolve: "gatsby-plugin-mdx",
options: {
extensions: [".mdx", ".md"],
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 1382,
disableBgImageOnAlpha: true
},
},
// Copies linked files from Markdown to public directory (ie for gifs)
`gatsby-remark-copy-linked-files`,
],
remarkPlugins: [require("remark-slug")]
}
},
{
resolve: "gatsby-plugin-material-ui",
options: {
stylesProvider: {
disableGeneration: true
},
},
},
{
resolve: "gatsby-plugin-manifest",
options: {
name: "Cloudflare docs",
short_name: "Docs",
start_url: "/",
background_color: "#f38020",
theme_color: "#f38020",
display: "minimal-ui",
icon: "src/images/cloudflare-icon.png"
}
},
// Consider enabling for PWA + offline functionality
// https://gatsby.dev/offline
// 'gatsby-plugin-offline',
{
resolve: "gatsby-plugin-google-tagmanager",
options: {
id: "GTM-PKQFGQB",
dataLayerName: "cfDataLayer",
selfHostedOrigin: "https://tr.www.cloudflare.com"
},
},
],
}