diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 417b21853b83..d444b007aaa2 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 fe8c01bcfa7f..b3116b444f95 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.