Skip to content

Commit

Permalink
chore(frontmatter): dealias created/modified/updated time
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
  • Loading branch information
aarnphm committed Dec 21, 2024
1 parent ff9e60a commit ef00f67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 15 additions & 0 deletions quartz/plugins/transformers/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options>> = (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
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions quartz/plugins/transformers/lastmod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (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.
Expand Down

0 comments on commit ef00f67

Please sign in to comment.