diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro index 3ade70d..74b48bb 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[slug].astro @@ -48,6 +48,24 @@ const formatDate = (date) => { }); }; +// Generate datetime attribute safely +const getISODate = (date) => { + if (!date) return ''; + // Handle various date formats + try { + // If already a Date object + if (date instanceof Date) { + return date.toISOString(); + } + // If it's a string or number, convert to Date + return new Date(date).toISOString(); + } catch (error) { + // Fallback if date is invalid + console.error('Invalid date format:', date); + return ''; + } +}; + // Get the Content component for rendering markdown const { Content } = await post.render(); --- @@ -57,7 +75,7 @@ const { Content } = await post.render();

{post.data.title}

- {post.data.pubDate && } + {post.data.pubDate && } {post.data.updatedDate &&
Updated: {formatDate(post.data.updatedDate)}
} {post.data.readTime &&
{post.data.readTime} read
} {post.data.author &&
By {post.data.author}
} diff --git a/src/pages/configurations/[slug].astro b/src/pages/configurations/[slug].astro index f958fbd..78aa7e8 100644 --- a/src/pages/configurations/[slug].astro +++ b/src/pages/configurations/[slug].astro @@ -35,20 +35,40 @@ const formatDate = (date) => { day: 'numeric' }); }; + +// Generate datetime attribute safely +const getISODate = (date) => { + if (!date) return ''; + // Handle various date formats + try { + // If already a Date object + if (date instanceof Date) { + return date.toISOString(); + } + // If it's a string or number, convert to Date + return new Date(date).toISOString(); + } catch (error) { + // Fallback if date is invalid + console.error('Invalid date format:', date); + return ''; + } +}; + +// Get the Content component for rendering markdown +const { Content } = await entry.render(); ---

{entry.data.title}

- {entry.data.pubDate && } + {entry.data.pubDate && } {entry.data.updatedDate &&
Updated: {formatDate(entry.data.updatedDate)}
}
- - +