
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@mikestreety/11ty-utils
Advanced tools
A collection of utilities I found myself using on every project. Open to MR/PR/Issues/suggestions
npm i --save @mikestreety/11ty-utils
In your .eleventy.js
, you then add it as a plugin
const utils = require("@mikestreety/11ty-utils");
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(utils);
};
Below are the utils included within the package. Along with using them in 11ty, you can also include the Javascript file and require
the module you need.
For example, if you want to use the dayOridinal
filter as a function in a data file, you can do:
const {dayOrdinal} = require('@mikestreety/11ty-utils/filters/date');
//...
dayOrdinal(post.date);
These are the filters included within the Utils
Turn a string into a URL friendly string (or slug). This is particularly useful, especially when building pagination or creating a collection from a JSON feed.
Example output: This is a string
becomes this-is-a-string
{{ post.data.title | slugify }}
slugify(date)
For use with a Javascript file:
const slugify = require('@mikestreety/11ty-utils/filters/slugify');
This is useful if you want to limit the number of posts on your homepage, for example.
Example use:
{% set postslist = collections.blog | limit(6) %}
{%- for entry in postslist -%}
//
{% endfor %}
If you require the functions in a Javascript file, you can require them, only including the functions you need. For example:
const {iso, utc} = require('@mikestreety/11ty-utils/filters/date');
Returns an ISO formatted date string , used for things like schema markup
Example output: 2011-10-05T14:48:00.000Z
{{ date | dateISO }}
iso(date)
Returns an ISO formatted date string without the time - useful for sitemaps
Example output: 2011-10-05
{{ date | dateISOShort }}
isoShort(date)
Returns a rfc7231 style UTC date string. For use with RSS
Example output: Tue, 06 Apr 2021 00:00:00 GMT
{{ date | dateUTC }}
utc(date)
A long date formatted with the ordinal and long month name
Example output: 22nd March 2021
{{ date | dateLong }}
longDate(date)
The day in number format
Example output: 22
or 6
day(date)
The day in number format with the ordinal (nth
, rd
) appended
Example output: 22nd
or 6th
dayOrdinal(date)
The month in a numerical format
Example output: 1
or 11
month(date)
The full name of the month
Example output: March
or December
monthName(date)
The full year
Example output: 2021
or 1995
year(date)
truncate
truncateWords
which does a number of wordstruncateChars
will do characters (meta desc as default)dateShort
in a DD/MM/YY format (although, America?)FAQs
Collection of common utlities for use with 11ty
We found that @mikestreety/11ty-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.