mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 19:46:23 +00:00
fix: more robust tags parsing
This commit is contained in:
parent
dafc9f318e
commit
359484c139
1 changed files with 12 additions and 4 deletions
|
@ -49,11 +49,19 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined>
|
||||||
data.title = file.stem ?? "Untitled"
|
data.title = file.stem ?? "Untitled"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.tags && !Array.isArray(data.tags)) {
|
if (data.tags) {
|
||||||
|
// coerce to array
|
||||||
|
if (!Array.isArray(data.tags)) {
|
||||||
|
data.tags = data.tags
|
||||||
|
.toString()
|
||||||
|
.split(oneLineTagDelim)
|
||||||
|
.map((tag: string) => tag.trim())
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all non-string tags
|
||||||
data.tags = data.tags
|
data.tags = data.tags
|
||||||
.toString()
|
.filter((tag: unknown) => typeof tag === "string" || typeof tag === "number")
|
||||||
.split(oneLineTagDelim)
|
.map((tag: string | number) => tag.toString())
|
||||||
.map((tag: string) => tag.trim())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// slug them all!!
|
// slug them all!!
|
||||||
|
|
Loading…
Reference in a new issue