From ef00f674b9db430c9dc37206a83e7322e0ab40a4 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Sat, 21 Dec 2024 15:22:45 -0500 Subject: [PATCH 1/6] chore(frontmatter): dealias created/modified/updated time Signed-off-by: Aaron Pham --- quartz/plugins/transformers/frontmatter.ts | 15 +++++++++++++++ quartz/plugins/transformers/lastmod.ts | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 417b21853b837..d444b007aaa2a 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -73,6 +73,18 @@ export const FrontMatter: QuartzTransformerPlugin> = (userOpts) const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"]) + const created = coalesceAliases(data, ["date", "created"]) + if (created) data.created = created + const modified = coalesceAliases(data, [ + "lastmod", + "updated", + "last-modified", + "modified", + ]) + if (modified) data.modified = modified + const published = coalesceAliases(data, ["publishDate", "published", "date"]) + if (published) data.published = published + if (socialImage) data.socialImage = socialImage // fill in frontmatter @@ -91,6 +103,9 @@ declare module "vfile" { } & Partial<{ tags: string[] aliases: string[] + modified: string + created: string + published: string description: string publish: boolean | string draft: boolean | string diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts index fe8c01bcfa7f9..b3116b444f958 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -49,10 +49,8 @@ export const CreatedModifiedDate: QuartzTransformerPlugin> = (u modified ||= st.mtimeMs } else if (source === "frontmatter" && file.data.frontmatter) { created ||= file.data.frontmatter.date as MaybeDate - modified ||= file.data.frontmatter.lastmod as MaybeDate - modified ||= file.data.frontmatter.updated as MaybeDate - modified ||= file.data.frontmatter["last-modified"] as MaybeDate - published ||= file.data.frontmatter.publishDate as MaybeDate + modified ||= file.data.frontmatter.modified as MaybeDate + published ||= file.data.frontmatter.published as MaybeDate } else if (source === "git") { if (!repo) { // Get a reference to the main git repo. From e0f86928368f8598b6620bb953b415e0549fc3e0 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Sun, 22 Dec 2024 10:18:50 -0500 Subject: [PATCH 2/6] Update quartz/plugins/transformers/lastmod.ts --- quartz/plugins/transformers/lastmod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts index b3116b444f958..fd5769263f3cd 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -48,7 +48,7 @@ export const CreatedModifiedDate: QuartzTransformerPlugin> = (u created ||= st.birthtimeMs modified ||= st.mtimeMs } else if (source === "frontmatter" && file.data.frontmatter) { - created ||= file.data.frontmatter.date as MaybeDate + created ||= file.data.frontmatter.created as MaybeDate modified ||= file.data.frontmatter.modified as MaybeDate published ||= file.data.frontmatter.published as MaybeDate } else if (source === "git") { From abf6b6a838dadaf46118d555e177d967648b6faa Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Mon, 23 Dec 2024 07:28:57 -0500 Subject: [PATCH 3/6] Update quartz/plugins/transformers/frontmatter.ts --- quartz/plugins/transformers/frontmatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index d444b007aaa2a..5ba8951f06995 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -73,7 +73,7 @@ export const FrontMatter: QuartzTransformerPlugin> = (userOpts) const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"]) - const created = coalesceAliases(data, ["date", "created"]) + const created = coalesceAliases(data, ["created", "date"]) if (created) data.created = created const modified = coalesceAliases(data, [ "lastmod", From 7ad365843efcc29f4fcce3fb710d3931203bda93 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Mon, 23 Dec 2024 07:29:43 -0500 Subject: [PATCH 4/6] Apply suggestions from code review --- quartz/plugins/transformers/frontmatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 5ba8951f06995..eb2e8737191b7 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -76,10 +76,10 @@ export const FrontMatter: QuartzTransformerPlugin> = (userOpts) const created = coalesceAliases(data, ["created", "date"]) if (created) data.created = created const modified = coalesceAliases(data, [ + "modified", "lastmod", "updated", "last-modified", - "modified", ]) if (modified) data.modified = modified const published = coalesceAliases(data, ["publishDate", "published", "date"]) From 48b7ee5ef8b3ca07ae8c1223153ac27af1d2f9cb Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Mon, 23 Dec 2024 07:30:55 -0500 Subject: [PATCH 5/6] Update quartz/plugins/transformers/frontmatter.ts --- quartz/plugins/transformers/frontmatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index eb2e8737191b7..31b3b64ac1d41 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -76,8 +76,8 @@ export const FrontMatter: QuartzTransformerPlugin> = (userOpts) const created = coalesceAliases(data, ["created", "date"]) if (created) data.created = created const modified = coalesceAliases(data, [ - "modified", "lastmod", + "modified", "updated", "last-modified", ]) From 8baeb598095be651d272d60447e3b92c1c5154b9 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Mon, 23 Dec 2024 14:21:17 -0500 Subject: [PATCH 6/6] chore: update changes from bao --- quartz/plugins/transformers/frontmatter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 31b3b64ac1d41..e00c700e0c6e6 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -76,13 +76,13 @@ export const FrontMatter: QuartzTransformerPlugin> = (userOpts) const created = coalesceAliases(data, ["created", "date"]) if (created) data.created = created const modified = coalesceAliases(data, [ - "lastmod", "modified", + "lastmod", "updated", "last-modified", ]) if (modified) data.modified = modified - const published = coalesceAliases(data, ["publishDate", "published", "date"]) + const published = coalesceAliases(data, ["published", "publishDate", "date"]) if (published) data.published = published if (socialImage) data.socialImage = socialImage