Skip to content

Commit

Permalink
fix: performance improvements
Browse files Browse the repository at this point in the history
return before cheerio.load if meta_generator is disabled
  • Loading branch information
SukkaW committed Aug 15, 2019
1 parent 48b506d commit 66fa0e7
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 66fa0e7

Please sign in to comment.