From 40a27d2ba2988db453b0b4ba2f93dae8e4d99aab Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 15 Apr 2024 23:13:36 +0200 Subject: format dates without milliseconds --- src/templates.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/templates.ts b/src/templates.ts index 3fa46fe..84ae695 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -80,7 +80,7 @@ async function renderHomepage(posts: Array): Promise { $post.find(".u-url").attr("href", post.url); $post .find(".dt-published") - .attr("datetime", post.date.toISOString()) + .attr("datetime", post.date.toISOString().replace(/\.\d{3}/, "")) .text(post.date.toISOString().slice(0, 10)); $post.appendTo($feed); } @@ -105,7 +105,7 @@ async function renderPost(file: Post, content: string) { $(".title").addClass("h-card p-author").attr("rel", "author"); $(".h-entry .dt-published") - .attr("datetime", file.date.toISOString()) + .attr("datetime", file.date.toISOString().replace(/\.\d{3}/, "")) .text(file.date.toISOString().slice(0, 10)); $(".h-entry .e-content").html(content); const categories = $(".h-entry .p-categories"); @@ -145,7 +145,7 @@ async function renderListPage(tag: string, posts: Post[]) { $post.find(".u-url").attr("href", post.url); $post .find(".dt-published") - .attr("datetime", post.date.toISOString()) + .attr("datetime", post.date.toISOString().replace(/\.\d{3}/, "")) .text(post.date.toISOString().slice(0, 10)); $post.appendTo($feed); } @@ -179,7 +179,9 @@ async function renderFeed(title: string, posts: Post[], tag?: string) { $feed.children("title").text(title); $feed.children("link").attr("href", config.base_url); $feed.children("id").text(makeTagURI(tag || "feed")); - $feed.children("updated").text(posts[0].date.toISOString()); + $feed + .children("updated") + .text(posts[0].date.toISOString().replace(/\.\d{3}/, "")); const $tpl = $("feed > entry").remove(); for (const post of posts) { @@ -189,7 +191,9 @@ async function renderFeed(title: string, posts: Post[], tag?: string) { .children("link") .attr("href", new URL(post.url, config.base_url).href); $post.children("id").text(makeTagURI(post.basename)); - $post.children("updated").text(post.date.toISOString()); + $post + .children("updated") + .text(post.date.toISOString().replace(/\.\d{3}/, "")); $post.find("author > name").text(config.title); $post.children("summary").text(post.description || ""); const content = marked.parse((await getPost(post.input)).content); -- cgit 1.4.1