Post about new bikes, manually set excerpt
Build and copy to prod / build-and-copy (push) Successful in 2m10s
Build and copy to prod / build-and-copy (push) Successful in 2m10s
This commit is contained in:
1 parent
85042de1dc
commit
aab2e16d37
13 files changed
+133
-42
No files matched your search
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user