Skip to content

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

Answered by simonswiss
Thisisjuke asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

The slug is not part of the data generated by Keystatic — since it's effectively stored as the file/folder name.

A common approach here when gathering data for a collection is to "augment" the object with something that stores the slug, if you need it:

const col = await reader.collections[resource].read(slug)
return { ...col, key: slug }

That way the key property will be available alongside the rest of the data.

Hope it helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simonswiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #262 on May 26, 2023 03:59.