Skip to content

Commit

Permalink
feat: Support space-delimited tags in FrontMatter transformer (jack…
Browse files Browse the repository at this point in the history
  • Loading branch information
samstokes authored Dec 5, 2023
1 parent 5196f3b commit a7e2080
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion quartz/plugins/transformers/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ 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) => {
const opts = { ...defaultOptions, ...userOpts }
return {
name: "FrontMatter",
markdownPlugins() {
const { oneLineTagDelim } = opts

return [
[remarkFrontmatter, ["yaml", "toml"]],
() => {
Expand All @@ -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())
}

Expand Down

0 comments on commit a7e2080

Please sign in to comment.