Skip to content

Fetching a draft post by slug #4535

Discussion options

You must be logged in to vote

Hey there @sebpowell! 👋

You can include/exclude drafts by filtering with the drafts path.

Here's all posts without drafts:
*[_type == "post" && !(_id in path('drafts.**'))]

Here's only the drafts:
*[_type == "post" && (_id in path('drafts.**'))]

➡️ Have a look here for more information: https://www.sanity.io/docs/drafts#ebfb408fa9b6

Cheers!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sebpowell
Comment options

Answer selected by sebpowell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants