Is your feature request related to a problem? Please describe.
Have you considered an option to contentTypes fields, to NOT add the field to Metadata automatically upon creating new content, unless a value is added afterwards or have a default value defined.
Describe the solution you'd like
Let's imagine, I wanted the option to add "aliases" (might be a Hugo thing only), and have added this as a field, but I would like that field to be added to my page/post only/if a value is added to that specific field before being added to the Metadata?
Thanks
**Is your feature request related to a problem? Please describe.**
Have you considered an option to contentTypes fields, to NOT add the field to Metadata automatically upon creating new content, unless a value is added afterwards or have a default value defined.
**Describe the solution you'd like**
Let's imagine, I wanted the option to add "aliases" (might be a Hugo thing only), and have added this as a field, but I would like that field to be added to my page/post only/if a value is added to that specific field before being added to the Metadata?
Thanks
<!-- github-sync-id:1658754154 -->
I believe this is what you are looking for @dotjesper: https://frontmatter.codes/docs/content-creation/field-conditions
<!-- github-comment-id:1500252724 -->
Sure, I tried that. For what I can gather, I can choose to show the field within the Front Matter dashboard, based on "something". However I am able to hide the field from the Front Matter dashboard, but the field is still being added to the Metadata in the markdown file - I was looking for the other way around :) Meaning, if the field is empty, it should not add the field to the metadata, but keep it visible in the Front Matter window.
I will try to have another go - thanks.
Sure, I tried that. For what I can gather, I can choose to show the field within the Front Matter dashboard, based on "something". However I am able to hide the field from the Front Matter dashboard, but the field is still being added to the Metadata in the markdown file - I was looking for the other way around :) Meaning, if the field is empty, it should not add the field to the metadata, but keep it visible in the Front Matter window.
I will try to have another go - thanks.
<!-- github-comment-id:1500267213 -->
Ah, ok, in that case, I misunderstood you. That is the behavior how it was in the beginning. Over time we added all the fields, and to me, it feels like a best practice to give all content the field they should need.
I can see that this could be a preference, maybe we should introduce a property on the content type to support this.
Ah, ok, in that case, I misunderstood you. That is the behavior how it was in the beginning. Over time we added all the fields, and to me, it feels like a best practice to give all content the field they should need.
I can see that this could be a preference, maybe we should introduce a property on the content type to support this.
<!-- github-comment-id:1500281193 -->
I have added a new property on the content type: clearEmpty; if you set its value to true it will not include the empty fields on content creation or remove them when empties during editing.
I have added a new property on the content type: `clearEmpty`; if you set its value to `true` it will not include the empty fields on content creation or remove them when empties during editing.
```json
{
"frontMatter.taxonomy.contentTypes": [
{
"name": "default",
"pageBundle": false,
"previewPath": null,
"clearEmpty": true,
"fields": [
...
]
}
]
}
```
<!-- github-comment-id:1708056139 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Is your feature request related to a problem? Please describe.
Have you considered an option to contentTypes fields, to NOT add the field to Metadata automatically upon creating new content, unless a value is added afterwards or have a default value defined.
Describe the solution you'd like
Let's imagine, I wanted the option to add "aliases" (might be a Hugo thing only), and have added this as a field, but I would like that field to be added to my page/post only/if a value is added to that specific field before being added to the Metadata?
Thanks
I believe this is what you are looking for @dotjesper: https://frontmatter.codes/docs/content-creation/field-conditions
Sure, I tried that. For what I can gather, I can choose to show the field within the Front Matter dashboard, based on "something". However I am able to hide the field from the Front Matter dashboard, but the field is still being added to the Metadata in the markdown file - I was looking for the other way around :) Meaning, if the field is empty, it should not add the field to the metadata, but keep it visible in the Front Matter window.
I will try to have another go - thanks.
Ah, ok, in that case, I misunderstood you. That is the behavior how it was in the beginning. Over time we added all the fields, and to me, it feels like a best practice to give all content the field they should need.
I can see that this could be a preference, maybe we should introduce a property on the content type to support this.
https://github.com/estruyf/vscode-front-matter/issues/609 is related to this.
I have added a new property on the content type:
clearEmpty; if you set its value totrueit will not include the empty fields on content creation or remove them when empties during editing.