chore(frontmatter): dealias created/modified/updated time (#1664)
This commit is contained in:
parent
ff9e60a7fc
commit
965f9e123c
2 changed files with 18 additions and 5 deletions
|
@ -73,6 +73,18 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options>> = (userOpts)
|
||||||
|
|
||||||
const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"])
|
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
|
if (socialImage) data.socialImage = socialImage
|
||||||
|
|
||||||
// fill in frontmatter
|
// fill in frontmatter
|
||||||
|
@ -91,6 +103,9 @@ declare module "vfile" {
|
||||||
} & Partial<{
|
} & Partial<{
|
||||||
tags: string[]
|
tags: string[]
|
||||||
aliases: string[]
|
aliases: string[]
|
||||||
|
modified: string
|
||||||
|
created: string
|
||||||
|
published: string
|
||||||
description: string
|
description: string
|
||||||
publish: boolean | string
|
publish: boolean | string
|
||||||
draft: boolean | string
|
draft: boolean | string
|
||||||
|
|
|
@ -48,11 +48,9 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
|
||||||
created ||= st.birthtimeMs
|
created ||= st.birthtimeMs
|
||||||
modified ||= st.mtimeMs
|
modified ||= st.mtimeMs
|
||||||
} else if (source === "frontmatter" && file.data.frontmatter) {
|
} 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.lastmod as MaybeDate
|
modified ||= file.data.frontmatter.modified as MaybeDate
|
||||||
modified ||= file.data.frontmatter.updated as MaybeDate
|
published ||= file.data.frontmatter.published as MaybeDate
|
||||||
modified ||= file.data.frontmatter["last-modified"] as MaybeDate
|
|
||||||
published ||= file.data.frontmatter.publishDate as MaybeDate
|
|
||||||
} else if (source === "git") {
|
} else if (source === "git") {
|
||||||
if (!repo) {
|
if (!repo) {
|
||||||
// Get a reference to the main git repo.
|
// Get a reference to the main git repo.
|
||||||
|
|
Loading…
Add table
Reference in a new issue