diff --git a/lib/plugins/filter/meta_generator.js b/lib/plugins/filter/meta_generator.js index 436db0be52..fd7b0c453b 100644 --- a/lib/plugins/filter/meta_generator.js +++ b/lib/plugins/filter/meta_generator.js @@ -4,13 +4,14 @@ let cheerio; const hexoGeneratorTag = ''; function hexoMetaGeneratorInject(data) { + const { config } = this; + if (!config.meta_generator) return; + if (!cheerio) cheerio = require('cheerio'); const $ = cheerio.load(data, {decodeEntities: false}); - const { config } = this; if (!($('meta[name="generator"]').length > 0) && - $('head').contents().length > 0 && - config.meta_generator) { + $('head').contents().length > 0) { $('head').prepend(hexoGeneratorTag.replace('%s', this.version)); return $.html();