11ty Utils - an NPM Package

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:

11ty Utils on NPM

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 👍

View this post on Github

You might also enjoy…

Mike Street

Written by Mike Street

Mike is a CTO and Lead Developer from Brighton, UK. He spends his time writing, cycling and coding. You can find Mike on Mastodon.