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

Bug? Empty variables are removed from frontmatter #327

Open
kevinpapst opened this issue Oct 17, 2024 · 3 comments
Open

Bug? Empty variables are removed from frontmatter #327

kevinpapst opened this issue Oct 17, 2024 · 3 comments

Comments

@kevinpapst
Copy link
Contributor

I promise this is one of the last 5 issues I open 😁

You have that code in place inside convert_posts which removes certain frontmatter variables.
I am using Jekyll since years now and Liquid has kinda autoboxes certain values like PHP, but I am using a lot of bool and empty string values in my current wordpress theme to check for conditions.

foreach ( $meta as $key => $value ) {
if ( ! is_numeric( $value ) && ! $value ) {
unset( $meta[ $key ] );
}
}

When I do the export, half of the variables are missing in my frontmatter in certain files. This makes it more complicated for me to write the correct code, because I cannot assume that the fields are always there.
Maybe its just my dev brain that tries toi make it failsafe, but also larger search&replace actions are more complicated, because the keys are available in some files and not others.

I simply commented the unset line, but I wanted to point out that this behavior is (for me) unexpected. An exporter should export and not make decisions of what is a key of value and which ones are "use-less". Can I ask for the why of that code?

I can raise a PR to remove this foreach, but I guess this one is again a matter of opinion and I can also include it in a PR where I am going to add some docs for the next person.

@benbalter
Copy link
Owner

I can raise a PR to remove this foreach

👍. Jekyll has a "no magic" philosophy, so removing that would make sense.

I don't recall the original motivation. I suspect plugins or just having an old blog gave me lots of empty / unnecessary fields. If anything, maybe put a filter there so folks can build their own logic if they really want it? But I agree, find and replace makes more sense.

@kevinpapst
Copy link
Contributor Author

@kun18911 linking to external sites without reasoning screams spam. definitely not going to click that.

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

3 participants
@benbalter @kevinpapst and others