about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-04-15 23:13:36 +0200
committerAlan Pearce2024-04-15 23:16:13 +0200
commit40a27d2ba2988db453b0b4ba2f93dae8e4d99aab (patch)
treea7444b99044b69d7e6182658a29ab98a011ff4c6
parent65eae18e49ef4214c312f2594e8a79a621d4c066 (diff)
downloadwebsite-40a27d2ba2988db453b0b4ba2f93dae8e4d99aab.tar.lz
website-40a27d2ba2988db453b0b4ba2f93dae8e4d99aab.tar.zst
website-40a27d2ba2988db453b0b4ba2f93dae8e4d99aab.zip
format dates without milliseconds
-rw-r--r--src/templates.ts14
1 files 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<Post>): Promise<string> {
     $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);