UNPKG

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