forked from cloudflare/cloudflare-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-svg-files.js
29 lines (25 loc) · 999 Bytes
/
create-svg-files.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
const {products} = require('./developers.cloudflare.com/current-products-list')
const fs = require("fs");
const path = require("path");
// In root product-icons folder, SVG files will be generated from the docs-config.js folder from each product
// To regenerate icons: yarn generate:icons
if (!fs.existsSync(path.join(__dirname, "./product-icons", "utf8"))) {
fs.mkdirSync("./product-icons", { recursive: true }, (err) => {
if(err) {
console.log('error during product folder creation', err)
}
});
}
for (let i = 0; i < products.length; i++) {
const productObject = products[i]
const product = require(`./products/${productObject.icon}/docs-config.js`)
if (typeof product.logoSVGContent === "undefined") {
console.log(`product ${product.product} has no logoSVGContent`);
continue;
}
console.log("creating SVG icon", product.productIconKey);
fs.writeFileSync(
`./product-icons/${product.productIconKey}.svg`,
product.logoSVGContent.toString()
);
}