diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 417b21853b837..e00c700e0c6e6 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, ["created", "date"]) + if (created) data.created = created + const modified = coalesceAliases(data, [ + "modified", + "lastmod", + "updated", + "last-modified", + ]) + if (modified) data.modified = modified + const published = coalesceAliases(data, ["published", "publishDate", "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..fd5769263f3cd 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -48,11 +48,9 @@ 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 - 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 + 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") { if (!repo) { // Get a reference to the main git repo.