lewisdale.dev/config/filters/excerpt.js
Lewis Dale a540c0f1a5
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 1m42s
Couple of li'l adjustments to styles, and formatting of excerpts
2024-03-14 07:34:33 +00:00

10 lines
328 B
JavaScript

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;
});
}