generated from inherentlee/11ty
big ol copy
This commit is contained in:
+13
-1
@@ -1,6 +1,18 @@
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
export default function (eleventyConfig) {
|
||||
/* Filter out a given url from the collection */
|
||||
eleventyConfig.addFilter("excludeFromCollection", function (collection=[], pageUrl=this.ctx.page.url) {
|
||||
return collection.filter(post => post.url !== pageUrl);
|
||||
});
|
||||
|
||||
/* Return only the collection items that match one or more tags */
|
||||
eleventyConfig.addFilter("filterByTags", function(collection=[], ...requiredTags) {
|
||||
return collection.filter(post => {
|
||||
return requiredTags.flat().some(tag => post.data.tags.includes(tag));
|
||||
});
|
||||
});
|
||||
|
||||
/* Return the keys used in an object */
|
||||
eleventyConfig.addFilter("getKeys", (target) => {
|
||||
return Object.keys(target);
|
||||
@@ -49,7 +61,7 @@ export default function (eleventyConfig) {
|
||||
|
||||
/* Filter out structural tags */
|
||||
eleventyConfig.addFilter("removeBasicTags", (tags) => {
|
||||
return tags.filter((tag) => ["all"].indexOf(tag) === -1);
|
||||
return tags.filter((tag) => ["all", "doublePagination"].indexOf(tag) === -1);
|
||||
});
|
||||
|
||||
/* What it says on the tin */
|
||||
|
||||
Reference in New Issue
Block a user