mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
feat: Support space-delimited tags in FrontMatter
transformer (#620)
This commit is contained in:
parent
5196f3b9db
commit
a7e20804f5
1 changed files with 5 additions and 1 deletions
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue