Skip to content

Commit 2eccc52

Browse files
authored
feat: Granularity in icons options (#312)
1 parent 90fb45d commit 2eccc52

File tree

6 files changed

+262
-80
lines changed

6 files changed

+262
-80
lines changed

package-lock.json

Lines changed: 70 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Please note: Favicons is tested on Node 10.13 and above.
2828
```js
2929
var favicons = require('favicons'),
3030
source = 'test/logo.png', // Source image(s). `string`, `buffer` or array of `string`
31-
configuration = {
31+
configuration = {
3232
path: "/", // Path for overriding default icons path. `string`
3333
appName: null, // Your application's name. `string`
3434
appShortName: null, // Your application's short_name. `string`. Optional. If not set, appName will be used
@@ -59,14 +59,14 @@ var favicons = require('favicons'),
5959
// * overlayGlow - apply glow effect after mask has been applied (applied by default for firefox). `boolean`
6060
// * overlayShadow - apply drop shadow after mask has been applied .`boolean`
6161
//
62-
android: true, // Create Android homescreen icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
63-
appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
64-
appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
65-
coast: true, // Create Opera Coast icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
66-
favicons: true, // Create regular favicons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
67-
firefox: true, // Create Firefox OS icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
68-
windows: true, // Create Windows 8 tile icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
69-
yandex: true // Create Yandex browser icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }`
62+
android: true, // Create Android homescreen icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
63+
appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
64+
appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
65+
coast: true, // Create Opera Coast icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
66+
favicons: true, // Create regular favicons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
67+
firefox: true, // Create Firefox OS icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
68+
windows: true, // Create Windows 8 tile icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
69+
yandex: true // Create Yandex browser icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources
7070
}
7171
},
7272
callback = function (error, response) {
@@ -82,6 +82,88 @@ var favicons = require('favicons'),
8282
favicons(source, configuration, callback);
8383
```
8484

85+
The default sources are as follow (groupped by platform):
86+
87+
```javascript
88+
{
89+
"android": [
90+
"android-chrome-144x144.png",
91+
"android-chrome-192x192.png",
92+
"android-chrome-256x256.png",
93+
"android-chrome-36x36.png",
94+
"android-chrome-384x384.png",
95+
"android-chrome-48x48.png",
96+
"android-chrome-512x512.png",
97+
"android-chrome-72x72.png",
98+
"android-chrome-96x96.png"
99+
],
100+
"appleIcon": [
101+
"apple-touch-icon-1024x1024.png",
102+
"apple-touch-icon-114x114.png",
103+
"apple-touch-icon-120x120.png",
104+
"apple-touch-icon-144x144.png",
105+
"apple-touch-icon-152x152.png",
106+
"apple-touch-icon-167x167.png",
107+
"apple-touch-icon-180x180.png",
108+
"apple-touch-icon-57x57.png",
109+
"apple-touch-icon-60x60.png",
110+
"apple-touch-icon-72x72.png",
111+
"apple-touch-icon-76x76.png",
112+
"apple-touch-icon-precomposed.png",
113+
"apple-touch-icon.png"
114+
],
115+
"appleStartup": [
116+
"apple-touch-startup-image-1125x2436.png",
117+
"apple-touch-startup-image-1136x640.png",
118+
"apple-touch-startup-image-1242x2208.png",
119+
"apple-touch-startup-image-1242x2688.png",
120+
"apple-touch-startup-image-1334x750.png",
121+
"apple-touch-startup-image-1536x2048.png",
122+
"apple-touch-startup-image-1620x2160.png",
123+
"apple-touch-startup-image-1668x2224.png",
124+
"apple-touch-startup-image-1668x2388.png",
125+
"apple-touch-startup-image-1792x828.png",
126+
"apple-touch-startup-image-2048x1536.png",
127+
"apple-touch-startup-image-2048x2732.png",
128+
"apple-touch-startup-image-2160x1620.png",
129+
"apple-touch-startup-image-2208x1242.png",
130+
"apple-touch-startup-image-2224x1668.png",
131+
"apple-touch-startup-image-2388x1668.png",
132+
"apple-touch-startup-image-2436x1125.png",
133+
"apple-touch-startup-image-2688x1242.png",
134+
"apple-touch-startup-image-2732x2048.png",
135+
"apple-touch-startup-image-640x1136.png",
136+
"apple-touch-startup-image-750x1334.png",
137+
"apple-touch-startup-image-828x1792.png"
138+
],
139+
"coast": [
140+
"coast-228x228.png"
141+
],
142+
"favicons": [
143+
"favicon-16x16.png",
144+
"favicon-32x32.png",
145+
"favicon-48x48.png",
146+
"favicon.ico"
147+
],
148+
"firefox": [
149+
"firefox_app_128x128.png",
150+
"firefox_app_512x512.png",
151+
"firefox_app_60x60.png"
152+
],
153+
"windows": [
154+
"mstile-144x144.png",
155+
"mstile-150x150.png",
156+
"mstile-310x150.png",
157+
"mstile-310x310.png",
158+
"mstile-70x70.png"
159+
],
160+
"yandex": [
161+
"yandex-browser-50x50.png"
162+
]
163+
}
164+
165+
```
166+
85167
You can programmatically access Favicons configuration (icon filenames, HTML, manifest files, etc) with:
86168

87169
```js

src/helpers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ module.exports = function(options) {
123123
},
124124

125125
preparePlatformOptions(platform) {
126+
const icons = options.icons[platform];
126127
const parameters =
127-
typeof options.icons[platform] === "object"
128-
? options.icons[platform]
129-
: {};
128+
typeof icons === "object" && !Array.isArray(icons) ? icons : {};
130129

131130
for (const key of Object.keys(parameters)) {
132131
if (

0 commit comments

Comments
 (0)