找到安装的hexo-next-title hexo-next-share hexo-next-exif hexo-next-utteranc
等插件的安装目录 在其目录下找到node_modules
目录
观察是否存在 next-util
目录,若存在打开该目录中的index.js
进行修改
注释调添加的before_generate
过滤器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| 'use strict';
const yaml = require('js-yaml'); const fs = require('fs'); const path = require('path'); const { merge } = require('lodash');
module.exports = function(hexo, pluginDir) { hexo.extend.filter.register('before_generate', function err() { }); this.hexo = hexo; this.pluginDir = pluginDir; this.getFilePath = function(file) { return this.pluginDir ? path.resolve(this.pluginDir, file) : file; }; this.getFileContent = function(file) { return fs.readFileSync(this.getFilePath(file), 'utf8'); }; this.defaultConfigFile = function(key, file) { const defaultConfig = file ? yaml.safeLoad(this.getFileContent(file)) : {}; this.hexo.config[key] = merge(defaultConfig[key], this.hexo.theme.config[key], this.hexo.config[key]); return this.hexo.config[key]; }; };
|