11ty Utils - an NPM Package
By Mike Street
I was spinning up yet another 11ty site the other night and realised I was copying over the same filter files from this site. slugify
and date
seem to the be ones I repeat everywhere, with length
(for specifying how many of a collection is output) coming in a second favourite.
To save me losing track (or losing sync) between all my projects, I decided to publish them in an NPM package:
Right now it contains some filters which you can also include as functions in JS files. I do this in the updated diary page code (of which you can read more about in the previous blog post: Build an 11ty calendar to list all your posts).
To use it, you can install it with:
npm i @mikestreety/11ty-utils
Then add it to you .eleventy.js
file with
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(require("@mikestreety/11ty-utils"));
};
I am open to suggestions, improvements or recommendations of expansion - raise an issue (or an MR) if you have an idea 👍