refactor plugins to be functions instead of classes

This commit is contained in:
Jacky Zhao 2023-06-11 23:26:43 -07:00
parent b8c011410d
commit 352075ae81
20 changed files with 464 additions and 507 deletions
quartz/plugins/filters

View file

@ -1,10 +1,9 @@
import { QuartzFilterPlugin } from "../types"
import { ProcessedContent } from "../vfile"
export class RemoveDrafts extends QuartzFilterPlugin {
name = "RemoveDrafts"
shouldPublish([_tree, vfile]: ProcessedContent): boolean {
export const RemoveDrafts: QuartzFilterPlugin<{}> = () => ({
name: "RemoveDrafts",
shouldPublish([_tree, vfile]) {
const draftFlag: boolean = vfile.data?.frontmatter?.draft ?? false
return !draftFlag
}
}
})

View file

@ -1,10 +1,9 @@
import { QuartzFilterPlugin } from "../types"
import { ProcessedContent } from "../vfile"
export class ExplicitPublish extends QuartzFilterPlugin {
name = "ExplicitPublish"
shouldPublish([_tree, vfile]: ProcessedContent): boolean {
export const ExplicitPublish: QuartzFilterPlugin = () => ({
name: "ExplicitPublish",
shouldPublish([_tree, vfile]) {
const publishFlag: boolean = vfile.data?.frontmatter?.publish ?? false
return publishFlag
}
}
})