Skip to content

Commit 496880d

Browse files
alamprosKyleAMathews
authored andcommitted
Move default icons to common file (#4867)
Fixes #4865
1 parent 3074b2a commit 496880d

File tree

5 files changed

+50
-46
lines changed

5 files changed

+50
-46
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/gatsby-node.js
22
/gatsby-ssr.js
33
/gatsby-browser.js
4+
/common.js
45
/app-shell.js

packages/gatsby-plugin-manifest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugins: [
4545
background_color: "#f7f0eb",
4646
theme_color: "#a2466c",
4747
display: "minimal-ui",
48-
icon: src/images/icon.png // This path is relative to the root of the site.
48+
icon: "src/images/icon.png" // This path is relative to the root of the site.
4949
},
5050
},
5151
];
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// default icons for generating icons
2+
exports.defaultIcons = [
3+
{
4+
"src": `icons/icon-48x48.png`,
5+
"sizes": `48x48`,
6+
"type": `image/png`,
7+
},
8+
{
9+
"src": `icons/icon-72x72.png`,
10+
"sizes": `72x72`,
11+
"type": `image/png`,
12+
},
13+
{
14+
"src": `icons/icon-96x96.png`,
15+
"sizes": `96x96`,
16+
"type": `image/png`,
17+
},
18+
{
19+
"src": `icons/icon-144x144.png`,
20+
"sizes": `144x144`,
21+
"type": `image/png`,
22+
},
23+
{
24+
"src": `icons/icon-192x192.png`,
25+
"sizes": `192x192`,
26+
"type": `image/png`,
27+
},
28+
{
29+
"src": `icons/icon-256x256.png`,
30+
"sizes": `256x256`,
31+
"type": `image/png`,
32+
},
33+
{
34+
"src": `icons/icon-384x384.png`,
35+
"sizes": `384x384`,
36+
"type": `image/png`,
37+
},
38+
{
39+
"src": `icons/icon-512x512.png`,
40+
"sizes": `512x512`,
41+
"type": `image/png`,
42+
},
43+
]
44+

packages/gatsby-plugin-manifest/src/gatsby-node.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
11
const fs = require(`fs`)
22
const Promise = require(`bluebird`)
33
const sharp = require(`sharp`)
4-
5-
// default icons for generating icons
6-
const defaultIcons = [
7-
{
8-
"src": `icons/icon-48x48.png`,
9-
"sizes": `48x48`,
10-
"type": `image/png`,
11-
},
12-
{
13-
"src": `icons/icon-72x72.png`,
14-
"sizes": `72x72`,
15-
"type": `image/png`,
16-
},
17-
{
18-
"src": `icons/icon-96x96.png`,
19-
"sizes": `96x96`,
20-
"type": `image/png`,
21-
},
22-
{
23-
"src": `icons/icon-144x144.png`,
24-
"sizes": `144x144`,
25-
"type": `image/png`,
26-
},
27-
{
28-
"src": `icons/icon-192x192.png`,
29-
"sizes": `192x192`,
30-
"type": `image/png`,
31-
},
32-
{
33-
"src": `icons/icon-256x256.png`,
34-
"sizes": `256x256`,
35-
"type": `image/png`,
36-
},
37-
{
38-
"src": `icons/icon-384x384.png`,
39-
"sizes": `384x384`,
40-
"type": `image/png`,
41-
},
42-
{
43-
"src": `icons/icon-512x512.png`,
44-
"sizes": `512x512`,
45-
"type": `image/png`,
46-
},
47-
]
4+
const defaultIcons = require(`./common.js`).defaultIcons
485

496
sharp.simd(true)
507

packages/gatsby-plugin-manifest/src/gatsby-ssr.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from "react"
22
import { withPrefix } from "gatsby-link"
3+
import { defaultIcons } from "./common.js"
4+
35

46
exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {
57

6-
const { icons } = pluginOptions
8+
const icons = pluginOptions.icons || defaultIcons
79
const iconPath = icons[0].src.substring(0, icons[0].src.lastIndexOf(`/`))
810

911
setHeadComponents([

0 commit comments

Comments
 (0)