mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 19:46:23 +00:00
fix: reland string coercion in title
This commit is contained in:
parent
2c69b0c97d
commit
c6546903f2
1 changed files with 8 additions and 9 deletions
|
@ -4,6 +4,7 @@ import { QuartzTransformerPlugin } from "../types"
|
||||||
import yaml from "js-yaml"
|
import yaml from "js-yaml"
|
||||||
import toml from "toml"
|
import toml from "toml"
|
||||||
import { slugTag } from "../../util/path"
|
import { slugTag } from "../../util/path"
|
||||||
|
import { QuartzPluginData } from "../vfile"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
delims: string | string[]
|
delims: string | string[]
|
||||||
|
@ -37,16 +38,18 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined>
|
||||||
})
|
})
|
||||||
|
|
||||||
// tag is an alias for tags
|
// tag is an alias for tags
|
||||||
if (data.tag !== null) {
|
if (data.tag) {
|
||||||
data.tags = data.tag.toString()
|
data.tags = data.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
// coerce title to string
|
// coerce title to string
|
||||||
if (data.title !== null) {
|
if (data.title) {
|
||||||
data.title = data.title.toString()
|
data.title = data.title.toString()
|
||||||
|
} else if (data.title === null || data.title === undefined) {
|
||||||
|
data.title = file.stem ?? "Untitled"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.tags !== null && !Array.isArray(data.tags)) {
|
if (data.tags && !Array.isArray(data.tags)) {
|
||||||
data.tags = data.tags
|
data.tags = data.tags
|
||||||
.toString()
|
.toString()
|
||||||
.split(oneLineTagDelim)
|
.split(oneLineTagDelim)
|
||||||
|
@ -57,11 +60,7 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined>
|
||||||
data.tags = [...new Set(data.tags?.map((tag: string) => slugTag(tag)))] ?? []
|
data.tags = [...new Set(data.tags?.map((tag: string) => slugTag(tag)))] ?? []
|
||||||
|
|
||||||
// fill in frontmatter
|
// fill in frontmatter
|
||||||
file.data.frontmatter = {
|
file.data.frontmatter = data as QuartzPluginData["frontmatter"]
|
||||||
title: file.stem ?? "Untitled",
|
|
||||||
tags: [],
|
|
||||||
...data,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue