aab2e16d37
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 2m10s
13 lines
434 B
JavaScript
13 lines
434 B
JavaScript
const createExcerpt = (post, limit ) => {
|
|
const withoutTags = post.content.replace(/(<([^>]+)>)/gi, "");
|
|
|
|
if (withoutTags.length > limit) {
|
|
return withoutTags.slice(0, limit) + " […]";
|
|
}
|
|
return withoutTags;
|
|
}
|
|
module.exports = function (eleventyConfig) {
|
|
eleventyConfig.addFilter('excerpt', (post, limit = 250) => {
|
|
return post.data.excerpt || createExcerpt(post, limit);
|
|
});
|
|
} |