Skip to content

Commit

Permalink
Merge pull request jackyzha0#1543 from saberzero1/draft-publish-string
Browse files Browse the repository at this point in the history
feat(filters): support "true" as valid for frontmatter filters
  • Loading branch information
saberzero1 authored Oct 22, 2024
2 parents 9f701e5 + ad52d09 commit d98a3a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion quartz/plugins/filters/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { QuartzFilterPlugin } from "../types"
export const RemoveDrafts: QuartzFilterPlugin<{}> = () => ({
name: "RemoveDrafts",
shouldPublish(_ctx, [_tree, vfile]) {
const draftFlag: boolean = vfile.data?.frontmatter?.draft === true
const draftFlag: boolean =
vfile.data?.frontmatter?.draft === true || vfile.data?.frontmatter?.draft === "true"
return !draftFlag
},
})
2 changes: 1 addition & 1 deletion quartz/plugins/filters/explicit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { QuartzFilterPlugin } from "../types"
export const ExplicitPublish: QuartzFilterPlugin = () => ({
name: "ExplicitPublish",
shouldPublish(_ctx, [_tree, vfile]) {
return vfile.data?.frontmatter?.publish === true
return vfile.data?.frontmatter?.publish === true || vfile.data?.frontmatter?.publish === "true"
},
})
4 changes: 2 additions & 2 deletions quartz/plugins/transformers/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ declare module "vfile" {
tags: string[]
aliases: string[]
description: string
publish: boolean
draft: boolean
publish: boolean | string
draft: boolean | string
lang: string
enableToc: string
cssclasses: string[]
Expand Down

0 comments on commit d98a3a0

Please sign in to comment.