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

Parse booleans from the frontmatter (fixes #79) #177

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

bnjbvr
Copy link
Contributor

@bnjbvr bnjbvr commented Dec 11, 2022

Hi! This allows parsing boolean values from the frontmatter, following the suggestion in #79 that true should mean 1, false or absence should mean 0.

It's just touching the function that parses values from the frontmatter. I've decided to not change parseFloatFromAny in general because that might require adapting each call site of this function to identify if it needed additional changes to handle booleans too. Also, I've had to tweak deepValue so it returned boolean values: since the function was returning string | null | any[], I kept that convention and the boolean is converted to a string before being returned (many call sites do if (deepValue) with the return value, so that might have been dangerous to just use the bool there).

Please take a look and let me know what you think! Thanks!

@Fenntasy
Copy link

I don't see what could go wrong by just adding:

    } else if (typeof toParse === "boolean") {
        value = toParse ? 1 : 0;
    }

But in any case, it would be a welcomed addition :)

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 6, 2023

I don't see what could go wrong by just adding:

Callers of parseFloatFromAny will do something like let value = parseFloatFromAny(otherValue); if (value) { ... }. That doesn't distinguish the case where value === false from the case where value === undefined (or null), that's why I took the most specific approach :)

@AndriiPetrovDev
Copy link

@bnjbvr How to install your version? I am really novice to JS

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 17, 2023

@AndrewPetrov Sorry, I don't recall precisely how I've done it, but basically you'd need to use my branch by git-pulling it, then follow the instructions to use a local plugin. Hope it helps a bit!

@SalahAdDin
Copy link

@AndrewPetrov Sorry, I don't recall precisely how I've done it, but basically, you'd need to use my branch by git-pulling it, then follow the instructions to use a local plugin. Hope it helps a bit!

Have you ever thought about releasing your fork?

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Mar 4, 2023

Well I thought this simple PR would be reviewed and accepted without too much trouble. Maybe there are ways we can support the maintainers here, and avoid forking the code ❤️

@pyrochlore Hi! Can you take a look please, and let me know what you think of this PR?

@PedroReyes
Copy link

Hello @pyrochlore ,

Could you take a look at the pull request?

This feature would be highly appreciated to work with other community plugins. Thanks in advanced and thanks @bnjbvr for the pull request proposal.

Best regards,
Pedro Reyes.

@itsonlyjames
Copy link

@pyrochlore Hello! Any updates on this?

I'd love to utilise frontmatter boolean values so as to integrate annotations into the calendar view!

@SalahAdDin
Copy link

@bnjbvr May you check this PR?

Thank you.

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Aug 3, 2023

@SalahAdDin there's not much more I can do; I opened this PR in the first place, and I'm not a maintainer of the project so I can't merge it myself.

@itsonlyjames
Copy link

@bnjbvr thanks for your initial work. It's frustrating that this is still open 8 months later.

Is @pyrochlore dead?

Do we fork this repository and start maintaining our own? I mean, last release was Feb...

@oyes77
Copy link

oyes77 commented Aug 5, 2023

where's the fork?

@melvinru
Copy link

melvinru commented Aug 7, 2023

@bnjbvr any chance you'll create a fork mentioning @pyrochlore because he left the project?

@itsonlyjames
Copy link

@bnjbvr any chance you'll create a fork mentioning @pyrochlore because he left the project?

Ideally we would take over this project so as to keep credit for @pyrochlore, however with his absense that is difficult..

I'm all for other options. Would be frustrating to have to get all users to move to another published plugin also..

@Pukimaa
Copy link

Pukimaa commented Sep 1, 2023

When using booleans, it replaces the frontmatter to use numbers instead. Is this an issue with the new properties updates?

@ghost
Copy link

ghost commented Sep 10, 2023

Chiming in to say I ran into this issues and this fix would be helpful!

@lazyguru
Copy link
Collaborator

lazyguru commented Nov 5, 2023

Thank you for your contribution @bnjbvr. Expect this to be released in the next few days.

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

Successfully merging this pull request may close these issues.

10 participants