feat: WordCount

This commit is contained in:
沈宇
2020-01-07 14:05:02 +08:00
parent 758b378e82
commit ca99e5de86
9 changed files with 148 additions and 4 deletions

13
scripts/filters/index.js Normal file
View File

@@ -0,0 +1,13 @@
'use strict';
const metaGeneratorPath = './meta_generator';
module.exports = hexo => {
/* const {
filter
} = hexo.extend; */
// filter.register('after_render:html', require('./meta_generator'));
};
// 保持过滤器最先执行
hexo.extend.filter.register('after_render:html', require(metaGeneratorPath), 1);

View File

@@ -0,0 +1,17 @@
'use strict';
const defaultConfig = require('../default_config');
function hexoMetaGeneratorInject(data) {
const config = defaultConfig;
if (!config.meta_generator || !data ||
data.match(/<meta\s+name=['|"]?generator['|"]?/i)) {
return;
}
const hexoGeneratorTag = `\n <meta name="generator" content="hexo-theme-yilia-plus">`;
return data.replace('</title>', '</title>' + hexoGeneratorTag);
}
module.exports = hexoMetaGeneratorInject;