Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax for checkboxes in frontmatter? #291

Closed
TechLifeWeb opened this issue Jan 10, 2024 · 10 comments
Closed

Syntax for checkboxes in frontmatter? #291

TechLifeWeb opened this issue Jan 10, 2024 · 10 comments

Comments

@TechLifeWeb
Copy link

Apologies if this has been posted but I looked around and didn't see it. I'm using version 1.13.1.

I see that checkboxes in frontmatter is supported now but how do you use it?
Trying to track a frontmatter check box called read. This code doesn't work. It does add up all the days I've had the item in my frontmatter but doesn't consider if the value is true or false.

searchType: frontmatter
searchTarget: read
folder: Daily
startDate: 2023-12-30
summary:
     template: "Reading - Longest Streak: {{maxStreak()}} day(s) | Current streak: {{currentStreak()}} day(s)"
     style: "font-size:small;"

I have seen people suggest the following and I guess it works but I wasn't sure that was the official way

searchType: text
searchTarget: 'read: true'
@lazyguru
Copy link
Collaborator

Yes the new checkbox format works in the latest version (it was fixed a few versions back). It should count the "checked" (true) values for you (it works in my personal vault). Can you double check your front matter by switching to source view and verifying it is using true and not 1?

@lazyguru
Copy link
Collaborator

I just looked it up. We added support in version 1.11.0

@lazyguru
Copy link
Collaborator

Hmm, also can you try with "month:" format instead of "summary:"? I just tried in my vault with summary and it has an issue. So might be something related to that

@lazyguru
Copy link
Collaborator

Never mind. Summary works (I use "Reading" and you use "read". Not only did I have the wrong word, but the search is also case-sensitive)

@TechLifeWeb
Copy link
Author

Never mind. Summary works (I use "Reading" and you use "read". Not only did I have the wrong word, but the search is also case-sensitive)

so this should work?

searchType: frontmatter
searchTarget: read

@lazyguru
Copy link
Collaborator

Yes, as long as you actually named the field "read" in your frontmatter and not "Read"

@JulianVJacobs
Copy link

This doesn't seem to be working for me. It seems to be adding any instance of the checkbox property to the streak regardless of whether it's true or false and I can't figure out why.

@souponaroom
Copy link
Contributor

The problem seems to be in expr.ts: To increment the streak counter in summary view, it only checks that the value of each object is not null. Since unchecked boxes are "false", which is distinct from null, the tracker considers it part of the streak. I may pull request a change (but I do not know typescript so sorry if I can't do it).

@lazyguru
Copy link
Collaborator

Yeah, no worries there. Since you did the effort of find the spot in the code with the issue I can take a look and try to fix it

@lazyguru
Copy link
Collaborator

1.13.2 has been released and this should now be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants