我刚刚将我的Hexo博客更新到最新版本.更新后,<! – more – >标签似乎停止工作.它不是在主页上显示摘录,而是显示所有内容.我正在使用Next主题.
我在hexo github上发现了一个问题:https://github.com/hexojs/hexo/pull/1519
这看起来像我遇到的问题.我尝试在本地编辑此文件,但没有任何反应,仍然无法正常工作.
当我直接在node_modules中编辑包时,是否有npm缓存或我需要清除的东西?
谢谢
最佳答案 您是否尝试删除node_modules目录并重新运行npm install?
暂时解决:
您必须通过在package.json中设置“hexo”:“hexo.stable.version”降级到Hexo的稳定版本,或者您可以添加自己的过滤器来完成主题的scripts文件夹中的工作.此文件将在Hexo启动时使用.将文件命名为:excerpt.js.完整路径将:your-blog / themes / next / scripts / excerpt.js
var rExcerpt = /<!-- ?more ?-->/;
hexo.extend.filter.register('after_post_render', function(data) {
var content = data.content;
if (rExcerpt.test(content)){
data.content = content.replace(rExcerpt, function(match, index){
data.excerpt = content.substring(0, index).trim();
data.more = content.substring(index + match.length).trim();
return '<a id="more"></a>';
});
} else {
data.excerpt = '';
data.more = content;
}
});
它应该工作.