UNPKG

885 BJavaScriptView Raw
1'use strict';
2
3module.exports = appleLinkTags;
4
5var hasTarget = require('./has-target');
6var resolveURL = require('./resolve-url');
7
8function appleLinkTags(manifest, config) {
9 if (manifest.apple === false) {
10 return [];
11 }
12
13 var links = [];
14 var sizes;
15 var rootURL = config.rootURL || '/';
16
17 var precomposed;
18
19 if(manifest.apple && manifest.apple.precomposed) {
20 precomposed = '-precomposed';
21 } else {
22 precomposed = '';
23 }
24
25 if (manifest.icons && manifest.icons.length) {
26 for(var icon of manifest.icons) {
27 if (!icon.targets || hasTarget(icon, 'apple')) {
28 if (icon.sizes) {
29 sizes = ` sizes="${icon.sizes}"`
30 } else {
31 sizes = '';
32 }
33
34 const url = resolveURL(rootURL, icon.src);
35
36 links.push(`<link rel="apple-touch-icon${precomposed}" href="${url}"${sizes}>`);
37 }
38 }
39 }
40
41 return links;
42}