{{ title }}
+Published on: {{ date | readableDate }}
+ + {{ content | safe }} +diff --git a/.eleventy.js b/.eleventy.js index d7d920e..c7d2dbc 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -3,6 +3,18 @@ module.exports = function(eleventyConfig) { eleventyConfig.addPassthroughCopy("src/css"); eleventyConfig.addPassthroughCopy("src/js"); eleventyConfig.addPassthroughCopy("src/resume"); + // Add a filter for readable dates using vanilla JS + eleventyConfig.addFilter("readableDate", dateObj => { + // The toLocaleDateString method can be used to format dates + // without any external libraries. + // The 'UTC' timeZone option is added to prevent off-by-one day errors. + return new Date(dateObj).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + timeZone: 'UTC' + }); + }); // Add a shortcode for the current year for the footer eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`); diff --git a/src/_includes/layout.njk b/src/_includes/layout.njk index 2542732..611f36a 100644 --- a/src/_includes/layout.njk +++ b/src/_includes/layout.njk @@ -19,6 +19,7 @@ {{ site.author.name }}