This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
mystic/themes/hueman/scripts/excerpt.js

15 lines
381 B
JavaScript
Raw Normal View History

2018-09-03 07:41:16 +00:00
/**
* 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;
});