Aaron Pham
2024-12-23 965f9e123ca8f6bd5342bf9fe8daaa3e3a58ee2e
chore(frontmatter): dealias created/modified/updated time (#1664)

2 files modified
23 ■■■■ changed files
quartz/plugins/transformers/frontmatter.ts 15 ●●●●● patch | view | raw | blame | history
quartz/plugins/transformers/lastmod.ts 8 ●●●●● patch | view | raw | blame | history
quartz/plugins/transformers/frontmatter.ts
@@ -73,6 +73,18 @@
            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 @@
    } & Partial<{
        tags: string[]
        aliases: string[]
        modified: string
        created: string
        published: string
        description: string
        publish: boolean | string
        draft: boolean | string
quartz/plugins/transformers/lastmod.ts
@@ -48,11 +48,9 @@
                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.