From ad52d095670f2a08a330d1d4ee5ed4bc784e65aa Mon Sep 17 00:00:00 2001 From: Emile Bangma Date: Tue, 22 Oct 2024 20:33:54 +0000 Subject: [PATCH] Feat(filters): Support "true" as valid for draft and publish frontmatter values (b3a02909ba74fff08cd3675707d1f4d782a24e98) --- quartz/plugins/filters/draft.ts | 3 ++- quartz/plugins/filters/explicit.ts | 2 +- quartz/plugins/transformers/frontmatter.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/quartz/plugins/filters/draft.ts b/quartz/plugins/filters/draft.ts index 09a3c3a..e8f1d4e 100644 --- a/quartz/plugins/filters/draft.ts +++ b/quartz/plugins/filters/draft.ts @@ -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 }, }) diff --git a/quartz/plugins/filters/explicit.ts b/quartz/plugins/filters/explicit.ts index 603b46d..e2558e8 100644 --- a/quartz/plugins/filters/explicit.ts +++ b/quartz/plugins/filters/explicit.ts @@ -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" }, }) diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 70a60d8..2e599aa 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -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[]