Skip to content

Commit 1a796d3

Browse files
gganchganchimeg
andauthored
adding schema and querying for logoSVGContent in prep for icon update (#366)
Co-authored-by: ganchimeg <[email protected]>
1 parent 82ebb59 commit 1a796d3

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

gatsby-config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const docsConfig = require("./docs-config.js")
2-
32
const isProduction = process.env.NODE_ENV === "production"
43

54
const getProduct = (name) => {
@@ -52,14 +51,16 @@ const products = [
5251
"workers",
5352
]
5453

54+
// TODO: Delete later
5555
const productIcons = {}
5656
products.forEach(name => {
5757
productIcons[name] = require(getProduct(name)).pathD
5858
})
5959

60-
// 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
60+
61+
// 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
6162
if (docsConfig.productIconKey && !docsConfig.productLogoPathD) {
62-
docsConfig.productLogoPathD = productIcons[docsConfig.productIconKey]
63+
docsConfig.productLogoPathD = productIcons.productIconKey ? productIcons[docsConfig.productIconKey] : ''
6364
}
6465

6566
const siteMetadata = docsConfig.siteMetadata
@@ -69,6 +70,7 @@ Object.keys(docsConfig).forEach(prop => {
6970
siteMetadata.cloudflareDocs[prop] = docsConfig[prop]
7071
})
7172

73+
// TODO: Delete later on
7274
siteMetadata.cloudflareDocs.productIcons = productIcons
7375

7476
// We exposed friendlier siteMetadata.url to Docs consumers but

gatsby-node.js

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
// See: https://www.gatsbyjs.org/docs/node-apis/
22

33
// https://www.gatsbyjs.org/docs/add-custom-webpack-config/
4-
exports.onCreateWebpackConfig = ({
5-
getConfig,
6-
actions,
7-
plugins,
8-
}) => {
4+
exports.onCreateWebpackConfig = ({ getConfig, actions, plugins }) => {
95
const config = getConfig()
106

117
// Hides "[HMR] ..." logs in devtools
128
if (config.entry.commons) {
13-
config.entry.commons = config.entry.commons.map(path => (
9+
config.entry.commons = config.entry.commons.map(path =>
1410
// Add query param to entry added by Gatsby CLI https://git.io/JvAC5
15-
path.indexOf('/webpack-hot-middleware/client.js?') > -1 ?
16-
path + '&quiet=true' : path
17-
))
11+
path.indexOf("/webpack-hot-middleware/client.js?") > -1
12+
? path + "&quiet=true"
13+
: path
14+
)
1815
}
1916

2017
actions.replaceWebpackConfig(config)
@@ -24,13 +21,12 @@ exports.onCreateWebpackConfig = ({
2421
// Hides React Devtools advertisement in devtools
2522
// https://tinyurl.com/hide-react-devtools-advert
2623
plugins.define({
27-
__REACT_DEVTOOLS_GLOBAL_HOOK__: "({ isDisabled: true })"
28-
})
29-
]
24+
__REACT_DEVTOOLS_GLOBAL_HOOK__: "({ isDisabled: true })",
25+
}),
26+
],
3027
})
3128
}
3229

33-
3430
const { createFilePath } = require("gatsby-source-filesystem")
3531

3632
exports.onCreateNode = ({ node, actions, getNode }) => {
@@ -42,12 +38,11 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
4238
createNodeField({
4339
name: "slug",
4440
node,
45-
value
41+
value,
4642
})
4743
}
4844
}
4945

50-
5146
const path = require("path")
5247

5348
exports.createPages = async ({ graphql, actions, reporter }) => {
@@ -97,7 +92,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
9792
createPage({
9893
path: node.fields.slug,
9994
component: path.resolve("./src/components/mdx-custom-renderer.js"),
100-
context: node
95+
context: node,
10196
})
10297
})
10398
}
@@ -131,6 +126,43 @@ exports.createSchemaCustomization = ({ actions }) => {
131126
132127
type Site {
133128
pathPrefix: String
129+
siteMetadata: SiteMetadata
130+
}
131+
132+
type CloudflareDocs {
133+
pathPrefix: String
134+
product: String
135+
productIconKey: String
136+
productLogoPathD: String
137+
logoSVGContent: String
138+
contentRepo: String
139+
contentRepoFolder: String
140+
search: AlgoliaSearch
141+
externalLinks: [ExternalLinksType]
142+
}
143+
144+
type ExternalLinksType {
145+
title: String
146+
url: String
147+
}
148+
149+
type AlgoliaOptions {
150+
facetFilters: String
151+
}
152+
153+
type AlgoliaSearch {
154+
indexName: String
155+
apiKey: String
156+
algoliaOptions: AlgoliaOptions
157+
}
158+
159+
type SiteMetadata {
160+
cloudflareDocs: CloudflareDocs
161+
title: String
162+
description: String
163+
author: String
164+
url: String
165+
image: String
134166
}
135167
`
136168

src/utils/get-cloudflare-docs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export default () => {
1818
cloudflareDocs {
1919
pathPrefix
2020
product
21+
productIconKey
2122
productLogoPathD
22-
# logoSVGContent
23+
logoSVGContent
2324
contentRepo
2425
contentRepoFolder
2526
externalLinks {

0 commit comments

Comments
 (0)