From 9a348e0e63343d2eebe90466356c3730982c5708 Mon Sep 17 00:00:00 2001 From: David Martin Date: Fri, 2 Aug 2024 15:07:38 +0100 Subject: [PATCH 1/2] Add blog nav with initial post Signed-off-by: David Martin --- .eleventy.js | 11 ++++++ src/_includes/layout.njk | 17 ++++---- src/_includes/layouts/post.njk | 21 ++++++++++ src/_includes/postslist.njk | 8 ++++ src/blog.njk | 13 +++++++ src/blog/blog.11tydata.js | 6 +++ src/blog/cncf-sandbox.md | 24 ++++++++++++ src/community.md | 2 + src/contributing.md | 2 + static/css/style.css | 71 +++++++++++++++++++++++++++++++++- 10 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 src/_includes/layouts/post.njk create mode 100644 src/_includes/postslist.njk create mode 100644 src/blog.njk create mode 100644 src/blog/blog.11tydata.js create mode 100644 src/blog/cncf-sandbox.md diff --git a/.eleventy.js b/.eleventy.js index f6f8766..915bc63 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,3 +1,4 @@ +const { DateTime } = require("luxon"); const markdownIt = require('markdown-it'); const markdownItAnchor = require('markdown-it-anchor'); const string = require('string') @@ -29,6 +30,16 @@ module.exports = function(eleventyConfig) { ); eleventyConfig.addPlugin(eleventyNavigationPlugin); + eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => { + // Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens + return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy"); + }); + + eleventyConfig.addFilter('htmlDateString', (dateObj) => { + // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string + return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); + }); + return { dir: { input: "src", diff --git a/src/_includes/layout.njk b/src/_includes/layout.njk index 363356b..44345a3 100644 --- a/src/_includes/layout.njk +++ b/src/_includes/layout.njk @@ -45,14 +45,11 @@ title: Kuadrant.io