Skip to content

Allow optional fields to default to an empty string #1988

@claygiffin

Description

@claygiffin

Is your feature request related to a problem? Please describe.
Currently, when a new post is created with optional fields, and those fields are left blank, the outputted .md file will omit those fields instead of returning an empty/null value. This can cause a problem when using GraphQL, which will fail to build when an undefined value is returned. However, it would function just fine with an empty string instead.

Describe the solution you'd like
We should allow empty strings as default values in the config file, and have those empty strings output in the markdown file.

Example:

- {label: "Empty Field", name: "emptyField", widget: "string", default: "", required: false }

would output in blog-post.md as:

---
emptyField: ""
---

Additional context
This actually seems to be what happens already, but only after a user has filled in the field, saved, and then edited it to be empty again. I would just like to expand this behavior to occur when the post is first created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions