generated from inherentlee/11ty
filters
This commit is contained in:
1 parent
9e64deb336
commit
f68cd37b08
1 file changed
+6
-6
+6
-6
@@ -18,12 +18,6 @@ export default function (eleventyConfig) {
|
|||||||
return collection.slice(0, n);
|
return collection.slice(0, n);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Check if a dateTime happened before the current dateTime */
|
|
||||||
eleventyConfig.addFilter("inThePast", (dateString) => {
|
|
||||||
if (DateTime.fromISO(dateString) < DateTime.now()) return true;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Check if dates occurred on the same day */
|
/* Check if dates occurred on the same day */
|
||||||
eleventyConfig.addFilter("dateStringsEqual", (dateString1, dateString2) => {
|
eleventyConfig.addFilter("dateStringsEqual", (dateString1, dateString2) => {
|
||||||
const date1 = DateTime.fromISO(dateString1);
|
const date1 = DateTime.fromISO(dateString1);
|
||||||
@@ -39,6 +33,12 @@ export default function (eleventyConfig) {
|
|||||||
return DateTime.fromISO(dateString, { zone: zone || "utc" }).toFormat("yyyy-LL-dd");
|
return DateTime.fromISO(dateString, { zone: zone || "utc" }).toFormat("yyyy-LL-dd");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Check if a dateTime happened before the current dateTime */
|
||||||
|
eleventyConfig.addFilter("inThePast", (dateString) => {
|
||||||
|
if (DateTime.fromISO(dateString) < DateTime.now()) return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
/* What it says on the tin */
|
/* What it says on the tin */
|
||||||
eleventyConfig.addFilter("randomize", function (array) {
|
eleventyConfig.addFilter("randomize", function (array) {
|
||||||
// Create a copy of the array to avoid modifying the original
|
// Create a copy of the array to avoid modifying the original
|
||||||
|
|||||||
Reference in new issue
Block a user