lewisdale.dev/config/filters/excerpt.js

10 lines
328 B
JavaScript
Raw Normal View History

module.exports = function (eleventyConfig) {
eleventyConfig.addFilter('excerpt', (content, limit = 250) => {
const withoutTags = content.replace(/(<([^>]+)>)/gi, "");
if (withoutTags.length > limit) {
return withoutTags.slice(0, limit) + " […]";
}
return withoutTags;
});
}