-
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Handle empty matter #65
Comments
Specifically we would need the front matter to be empty to tell Jekyll that it should process the file. If it is stripped away by formatting then Jekyll copies the file verbatim. |
Why not just re-add empty front matter blocks when no data is returned? |
@jonschlinkert we have a lot of files, some contain matter blocks some not, we can't add matter blocks always |
We could possibly add an option for this, but the implementor (prettier) would still need to allow users to pass options to gray-matter. Fwiw, we can't make this default behavior since it's not desirable behavior for any other implementation I've seen besides this use case. Here is an example of how I personally would handle it (in prettier I guess, if they decide this should be handled there. if they don't we can discuss other options): const str = `---
---
This is content`;
const file = matter(str);
console.log(file);
if (file.matter === '') {
file.content = str;
}
console.log(file); edited: I updated the example. |
actually, we might need to do a little more than what I did in my example since users often add comments to front-matter. Instead of |
@jonschlinkert we don't add new options, all should work with zero configuration,when we parse files without matter we always have |
A work around is to add nonsense data. But it is nonsense data which is less optimal than leaving the empty blocks. |
that's a great idea, I'll push something up! |
Okay, after playing around with this. I propose we add an thoughts? |
I think the |
@jonschlinkert |
Great, I'll push it up. |
@jonschlinkert friendly ping 👍 |
Thanks for the reminder, I'll work on this today! |
Published to npm and git tagged as 4.0. Thanks for the issue |
Input:
Maybe return
file.empty
option.Based on prettier/prettier#4162 (comment)
The text was updated successfully, but these errors were encountered: