1 | 'use strict';
|
2 |
|
3 | module.exports = faviconLinkTags;
|
4 |
|
5 | const hasTarget = require('./has-target');
|
6 | const resolveURL = require('./resolve-url');
|
7 | const resolveRootURL = require('./resolve-root-url');
|
8 |
|
9 | function faviconLinkTags(manifest, config) {
|
10 | const links = [];
|
11 | const rootURL = resolveRootURL(config);
|
12 |
|
13 | if (manifest.icons && manifest.icons.length) {
|
14 | for (let icon of manifest.icons) {
|
15 | if (hasTarget(icon, 'favicon')) {
|
16 | let sizes = '';
|
17 | if (icon.sizes) {
|
18 | sizes = ` sizes="${icon.sizes}"`
|
19 | }
|
20 |
|
21 | let type = '';
|
22 | if (icon.type) {
|
23 | type = ` type="${icon.type}"`
|
24 | }
|
25 |
|
26 | const url = resolveURL(rootURL, icon.src);
|
27 |
|
28 | links.push(`<link rel="icon" href="${url}"${sizes}${type}>`);
|
29 | }
|
30 | }
|
31 | }
|
32 |
|
33 | return links;
|
34 | }
|