Skip to content

Commit

Permalink
fix: make filter checks more strict (closes #1519)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Oct 15, 2024
1 parent 1dc2083 commit b3a0290
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion quartz/plugins/filters/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { QuartzFilterPlugin } from "../types"
export const RemoveDrafts: QuartzFilterPlugin<{}> = () => ({
name: "RemoveDrafts",
shouldPublish(_ctx, [_tree, vfile]) {
const draftFlag: boolean = vfile.data?.frontmatter?.draft || false
const draftFlag: boolean = 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 ?? false
return vfile.data?.frontmatter?.publish === true
},
})

5 comments on commit b3a0290

@eminence
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a bunch of pages with publish: "true" (which is the default data type that Obsidian uses), and this change caused them all to be unpublished. Would you consider perhaps explicitly looking for the string "true" within the filter plugin?

@saberzero1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a bunch of pages with publish: "true" (which is the default data type that Obsidian uses), and this change caused them all to be unpublished. Would you consider perhaps explicitly looking for the string "true" within the filter plugin?

You can change the publish frontmatter tag to a boolean value. In Obsidian this would be a checkbox in Live Preview mode.

@eminence
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, understood. But I'm wondering if there's anything that can be done besides updating every file in my vault.

To be clear, my suggestion is basically:

return vfile.data?.frontmatter?.publish === "true" || vfile.data?.frontmatter?.publish === true

@jackyzha0
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to make a pr for that, happy to make that change

@saberzero1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to make a pr for that, happy to make that change

#1543

Please sign in to comment.