From 0d3cf2922618774fc397dca8cb92fcf76fb0db02 Mon Sep 17 00:00:00 2001
From: Ben Schlegel <31989404+benschlegel@users.noreply.github.com>
Date: Mon, 18 Sep 2023 21:32:00 +0000
Subject: [PATCH] docs: fix explorer example (#483)
---
quartz/plugins/transformers/lastmod.ts | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts
index 507b585..015c350 100644
--- a/quartz/plugins/transformers/lastmod.ts
+++ b/quartz/plugins/transformers/lastmod.ts
@@ -11,6 +11,11 @@
priority: ["frontmatter", "git", "filesystem"],
}
+function coerceDate(d: any): Date {
+ const dt = new Date(d)
+ return isNaN(dt.getTime()) ? new Date() : dt
+}
+
type MaybeDate = undefined | string | number
export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options> | undefined> = (
userOpts,
@@ -49,9 +54,9 @@
}
file.data.dates = {
- created: created ? new Date(created) : new Date(),
- modified: modified ? new Date(modified) : new Date(),
- published: published ? new Date(published) : new Date(),
+ created: coerceDate(created),
+ modified: coerceDate(modified),
+ published: coerceDate(published),
}
}
},
--
Gitblit v1.10.0