feat: Support space-delimited tags in FrontMatter transformer (#620)

This commit is contained in:
Sam Stokes 2023-12-04 18:18:47 -08:00 committed by GitHub
parent 5196f3b9db
commit a7e20804f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,11 +8,13 @@ import { slugTag } from "../../util/path"
export interface Options {
delims: string | string[]
language: "yaml" | "toml"
oneLineTagDelim: string
}
const defaultOptions: Options = {
delims: "---",
language: "yaml",
oneLineTagDelim: ",",
}
export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => {
@ -20,6 +22,8 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined>
return {
name: "FrontMatter",
markdownPlugins() {
const { oneLineTagDelim } = opts
return [
[remarkFrontmatter, ["yaml", "toml"]],
() => {
@ -45,7 +49,7 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options> | undefined>
if (data.tags && !Array.isArray(data.tags)) {
data.tags = data.tags
.toString()
.split(",")
.split(oneLineTagDelim)
.map((tag: string) => tag.trim())
}