Skip to content

Commit

Permalink
Merge pull request #3667 from SukkaW/meta-generator-config
Browse files Browse the repository at this point in the history
fix: performance improvements when meta_generator is disabled
  • Loading branch information
curbengh committed Aug 15, 2019
2 parents 48b506d + 66fa0e7 commit 3176fe0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/plugins/filter/meta_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ let cheerio;
const hexoGeneratorTag = '<meta name="generator" content="Hexo %s" />';

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();
Expand Down

0 comments on commit 3176fe0

Please sign in to comment.