Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/hexo/default_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ module.exports = {
deploy: {},

// ignore files from processing
ignore: []
ignore: [],

// Category & Tag
meta_generator: true
};

5 changes: 4 additions & 1 deletion lib/plugins/filter/meta_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const hexoGeneratorTag = '<meta name="generator" content="Hexo %s" />';
function hexoMetaGeneratorInject(data) {
if (!cheerio) cheerio = require('cheerio');
const $ = cheerio.load(data, {decodeEntities: false});
const { config } = this;

if (!($('meta[name="generator"]').length > 0) && $('head').contents().length > 0) {
if (!($('meta[name="generator"]').length > 0) &&
$('head').contents().length > 0 &&
config.meta_generator) {
$('head').prepend(hexoGeneratorTag.replace('%s', this.version));

return $.html();
Expand Down
9 changes: 9 additions & 0 deletions test/scripts/filters/meta_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ describe('Meta Generator', () => {
const resultType = typeof result;
resultType.should.eql('undefined');
});

it('disable meta_generator', () => {
const content = '<head><link></head>';
hexo.config.meta_generator = false;
const result = metaGenerator(content);

const resultType = typeof result;
resultType.should.eql('undefined');
});
});