sbbs/themes/hueman/scripts/excerpt.js
2018-09-03 17:41:16 +10:00

15 lines
381 B
JavaScript

/**
* Excerpt Helper
* @description Get the excerpt from a post
* @example
* <%- excerpt(post) %>
*/
hexo.extend.helper.register('excerpt', function (post) {
var excerpt;
if (post.excerpt) {
excerpt = post.excerpt.replace(/\<[^\>]+\>/g, '');
} else {
excerpt = post.content.replace(/\<[^\>]+\>/g, '').substring(0, 200);
}
return excerpt;
});