feat: Support space-delimited tags in `FrontMatter` transformer (#620)
| | |
| | | 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) => { |
| | |
| | | return { |
| | | name: "FrontMatter", |
| | | markdownPlugins() { |
| | | const { oneLineTagDelim } = opts |
| | | |
| | | return [ |
| | | [remarkFrontmatter, ["yaml", "toml"]], |
| | | () => { |
| | |
| | | if (data.tags && !Array.isArray(data.tags)) { |
| | | data.tags = data.tags |
| | | .toString() |
| | | .split(",") |
| | | .split(oneLineTagDelim) |
| | | .map((tag: string) => tag.trim()) |
| | | } |
| | | |