1 | ;
|
2 |
|
3 | let cheerio;
|
4 | const hexoGeneratorTag = '<meta name="generator" content="Hexo %s" />';
|
5 |
|
6 | function hexoMetaGeneratorInject(data) {
|
7 | if (!cheerio) cheerio = require('cheerio');
|
8 | const $ = cheerio.load(data, {decodeEntities: false});
|
9 |
|
10 | if (!($('meta[name="generator"]').length > 0)) {
|
11 | $('head').prepend(hexoGeneratorTag.replace('%s', this.version));
|
12 |
|
13 | return $.html();
|
14 | }
|
15 | }
|
16 |
|
17 | module.exports = hexoMetaGeneratorInject;
|