Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 'use strict'; const xmlbuilder = require('xmlbuilder'); const BaseManifest = require('../base-manifest'); const hasTarget = require('../utils/has-target'); const ALLOWED_ICON_ELEMENTS = [ 'square70x70logo', 'square150x150logo', 'wide310x150logo', 'square310x310logo', ]; module.exports = class Browserconfig extends BaseManifest { static get name() { return 'browserconfig.xml'; } static get selector() { return 'meta[name="msapplication-config"]'; } static get tag() { return '<meta name="msapplication-config" content="{{rootURL}}browserconfig.xml">'; } constructor(app) { super(app, { name: Browserconfig.name, selector: Browserconfig.selector }); } generate() { let manifest = { browserconfig: { msapplication: {}, }, }; this.tile(manifest, this.configuration); return xmlbuilder.create(manifest).end(); } tile(manifest, configuration) { if (!configuration.icons) { return; } let icons = configuration.icons.filter(icon => hasTarget(icon, 'ms')); if (!icons.length) { return; } if (!configuration.ms || !configuration.ms.tileColor) { throw new Error( `Property 'ms.tileColor' missing to generate ${this.name}` ); } manifest.browserconfig.msapplication.tile = {}; this.icons(manifest, icons); this.color(manifest, configuration.ms.tileColor); } icons(manifest, icons) { icons.forEach(icon => { if (!ALLOWED_ICON_ELEMENTS.includes(icon.element)) { throw new Error( `The 'element' property of the icon for ${ this.name } must be one of ${ALLOWED_ICON_ELEMENTS.join(', ')}` ); } manifest.browserconfig.msapplication.tile[icon.element] = { '@src': icon.src, }; }); } color(manifest, color) { manifest.browserconfig.msapplication.tile.TileColor = { '#text': color, }; } }; |