From 698707c65c9fc3f06a55f7e870c3685756138c6f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 27 Feb 2023 20:55:42 -0800 Subject: [PATCH] Show article updated date if applicable --- script.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index 27b607c..f2c59fa 100644 --- a/script.js +++ b/script.js @@ -45,8 +45,8 @@ async function fetchPostMetadata() { description: row[1], id: row[2], linkText: row[3], - createdDate: new Date(row[5]).toLocaleDateString(), - updatedDate: new Date(row[6]).toLocaleDateString(), + createdDate: new Date(row[5]), + updatedDate: new Date(row[6]), tags: row[7].split(',').map(s => s.trim()) }); } @@ -60,10 +60,13 @@ function buildHomeComponent(metadata) { home.classList.add('card-container'); for (const [path, post] of metadata) { + const subtitle = post.createdDate.toISOString() === post.updatedDate.toISOString() ? + `` : + ` — Updated `; home.insertAdjacentHTML('beforeend', `

${post.title}

-

${post.createdDate}

+

${subtitle}

${post.description}

${post.linkText}

-- 2.47.3