Skip to content

Missing key value in the case of simple key/value pairing  #262

@Thisisjuke

Description

@Thisisjuke

I wanted to do a simple key value to handle common error strings inside my forms:
image

keystatic.config.js

formCommon: collection({
            label: 'Form Common Texts',
            path: 'src/modules/keystatic/content/form-common/*/',
            slugField: 'key',
            schema: {
                key: fields.text({
                    label: 'Key',
                    validation: { length: { min: 1 } },
                }),
                value: fields.text({
                    label: 'Value',
                    validation: { length: { min: 1 } },
                }),
            },
        }),

When log the content of my data, I have :
image

I updated my package.json to:

    "@keystatic/core": "^0.0.98",
    "@keystatic/next": "^0.0.7",

Now, I have to do this:

const col = await reader.collections[resource].read(slug)
if (col && 'key' in col && col?.key === null) {
    col.key = slug
}
return col

It's easy to remap it because I just asked .read(slug) .

Expected Behavior

I want to have the slug by default when I ask for a key + value object so I don't have to set the key (slug) by myself.

Current Behavior

Slug is null.

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