blog-hexo/themes/hexo-theme-linear/scripts/generate_excerpt.js
2023-10-19 21:55:22 +08:00

6 lines
244 B
JavaScript

hexo.extend.helper.register('generate_excerpt', function (post, length) {
length = length || 100;
const strippedContent = post.content.replace(/<\/?[^>]+(>|$)/g, ""); // 删除 HTML 标签
return strippedContent.substring(0, length);
});