Post about new bikes, manually set excerpt
Build and copy to prod / build-and-copy (push) Successful in 2m10s

This commit is contained in:
Lewis Dale committed 2024-04-24 20:28:51 +01:00
1 parent 85042de1dc
commit aab2e16d37
13 files changed
+133 -42

No files matched your search

+6 -3
View File
@@ -1,10 +1,13 @@
module.exports = function (eleventyConfig) {
eleventyConfig.addFilter('excerpt', (content, limit = 250) => {
const withoutTags = content.replace(/(<([^>]+)>)/gi, "");
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);
});
}