v1.18.x
Julian Lam 10 years ago
parent c26f274392
commit a72501f3b4

@ -1,12 +1,14 @@
var nconf = require('nconf'), var nconf = require('nconf'),
validator = require('validator'), validator = require('validator'),
async = require('async'),
plugins = require('../plugins'); plugins = require('../plugins');
module.exports = function(Meta) { module.exports = function(Meta) {
Meta.tags = {}; Meta.tags = {};
Meta.tags.parse = function(meta, link, callback) { Meta.tags.parse = function(meta, link, callback) {
var defaultMetaTags = [{ async.parallel([
async.apply(plugins.fireHook, 'filter:meta.getMetaTags', [{
name: 'viewport', name: 'viewport',
content: 'width=device-width, initial-scale=1.0, user-scalable=no' content: 'width=device-width, initial-scale=1.0, user-scalable=no'
}, { }, {
@ -27,13 +29,13 @@ module.exports = function(Meta) {
}, { }, {
name: 'msapplication-square150x150logo', name: 'msapplication-square150x150logo',
content: Meta.config['brand:logo'] || '' content: Meta.config['brand:logo'] || ''
}], }]),
defaultLinkTags = [{ async.apply(plugins.fireHook, 'filter:meta.getLinkTags', [{
rel: 'apple-touch-icon', rel: 'apple-touch-icon',
href: nconf.get('relative_path') + '/apple-touch-icon' href: nconf.get('relative_path') + '/apple-touch-icon'
}]; }])
], function(err, tags) {
meta = defaultMetaTags.concat(meta || []).map(function(tag) { meta = tags[0].concat(meta || []).map(function(tag) {
if(!tag || typeof tag.content !== 'string') { if(!tag || typeof tag.content !== 'string') {
winston.warn('Invalid meta tag. ', tag); winston.warn('Invalid meta tag. ', tag);
return tag; return tag;
@ -43,7 +45,7 @@ module.exports = function(Meta) {
return tag; return tag;
}); });
link = defaultLinkTags.concat(link || []); link = tags[1].concat(link || []);
link.unshift({ link.unshift({
rel: "icon", rel: "icon",
type: "image/x-icon", type: "image/x-icon",
@ -54,5 +56,6 @@ module.exports = function(Meta) {
meta: meta, meta: meta,
link: link link: link
}); });
});
}; };
}; };
Loading…
Cancel
Save