From 19f84d218806c0dbd17a1b92b991614578730130 Mon Sep 17 00:00:00 2001
From: Lumither Tao
Date: Tue, 10 Dec 2024 04:00:10 -0800
Subject: [PATCH] fix(blog::post::footer) remove update_date section if
undefined
---
frontend/app/blog/post/[id]/Footer.tsx | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/frontend/app/blog/post/[id]/Footer.tsx b/frontend/app/blog/post/[id]/Footer.tsx
index 3c71bc2..6802851 100644
--- a/frontend/app/blog/post/[id]/Footer.tsx
+++ b/frontend/app/blog/post/[id]/Footer.tsx
@@ -17,7 +17,7 @@ const Footer = (props: Props) => {
const author = post['meta']['author'] ?? 'Tao';
const author_link = post['meta']['author_link'] ?? '/about';
const post_date = new Date(post['first_update']);
- const update_date = new Date(post['last_update']);
+ const update_date: Date | undefined = post['last_update'] ? new Date(post['last_update']) : undefined;
const cc = post['meta']['cc'] ?? 'by-nc-sa';
@@ -55,14 +55,16 @@ const Footer = (props: Props) => {
year: `numeric`
}) }
-
-
Updated on
-
{ update_date.toLocaleString('default', {
- month: `long`,
- day: `numeric`,
- year: `numeric`
- }) }
-
+ { update_date &&
+
+
Updated on
+
{ update_date.toLocaleString('default', {
+ month: `long`,
+ day: `numeric`,
+ year: `numeric`
+ }) }
+
+ }