From f5d8f6ad560748263a073a92fe64855d835fcc12 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Tue, 6 Aug 2019 20:34:59 +0930 Subject: [PATCH 1/2] feat: add option to disable meta generator tag --- lib/hexo/default_config.js | 5 ++++- lib/plugins/filter/meta_generator.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/hexo/default_config.js b/lib/hexo/default_config.js index 8a5086d07a..d4b334b81b 100644 --- a/lib/hexo/default_config.js +++ b/lib/hexo/default_config.js @@ -54,6 +54,9 @@ module.exports = { deploy: {}, // ignore files from processing - ignore: [] + ignore: [], + + // Category & Tag + meta_generator: true }; diff --git a/lib/plugins/filter/meta_generator.js b/lib/plugins/filter/meta_generator.js index 541eab5e8b..436db0be52 100644 --- a/lib/plugins/filter/meta_generator.js +++ b/lib/plugins/filter/meta_generator.js @@ -6,8 +6,11 @@ const hexoGeneratorTag = ''; 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(); From 5d592ccf4370aa298bf7df90af46d690fc3a55ee Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Tue, 6 Aug 2019 20:41:44 +0930 Subject: [PATCH 2/2] test: add test for meta_generator option --- test/scripts/filters/meta_generator.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/scripts/filters/meta_generator.js b/test/scripts/filters/meta_generator.js index 2ae4745c26..33473466e9 100644 --- a/test/scripts/filters/meta_generator.js +++ b/test/scripts/filters/meta_generator.js @@ -23,4 +23,13 @@ describe('Meta Generator', () => { const resultType = typeof result; resultType.should.eql('undefined'); }); + + it('disable meta_generator', () => { + const content = ''; + hexo.config.meta_generator = false; + const result = metaGenerator(content); + + const resultType = typeof result; + resultType.should.eql('undefined'); + }); });