From: Ardis Lu Date: Tue, 28 Feb 2023 04:55:42 +0000 (-0800) Subject: Show article updated date if applicable X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=698707c65c9fc3f06a55f7e870c3685756138c6f;p=ardislu.dev Show article updated date if applicable --- 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}