mirror of
https://github.com/danog/sass-site.git
synced 2024-12-12 09:29:58 +01:00
18 lines
622 B
TypeScript
18 lines
622 B
TypeScript
import formatDistanceToNowBase from 'date-fns/formatDistanceToNow';
|
|
|
|
/**
|
|
* Returns the distance between the given date and now in words.
|
|
*
|
|
* @see https://date-fns.org/docs/formatDistanceToNow
|
|
*/
|
|
export const formatDistanceToNow = (date: string) =>
|
|
formatDistanceToNowBase(new Date(date));
|
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access,
|
|
@typescript-eslint/no-unsafe-call,
|
|
@typescript-eslint/no-explicit-any */
|
|
export default function datesPlugin(eleventyConfig: any) {
|
|
// filters...
|
|
eleventyConfig.addLiquidFilter('formatDistanceToNow', formatDistanceToNow);
|
|
}
|