Skip to content

Commit

Permalink
add addFilter method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephraim-G committed Oct 7, 2024
1 parent 9d9fd79 commit b14ef84
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ module.exports = function (config) {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
});

// absoluteURL filter
config.addFilter('absoluteUrl', function(path) {
const baseUrl = process.env.BASEURL;
return new URL(path, baseUrl).href;
});

// Get the first `n` elements of a collection.
config.addFilter('head', (array, n) => {
if (!Array.isArray(array) || array.length === 0) {
Expand Down

0 comments on commit b14ef84

Please sign in to comment.