Last active
January 9, 2022 13:28
-
-
Save usulpro/f1812b436fdec496adf713f220d52d86 to your computer and use it in GitHub Desktop.
Can’t you still have references to your draft documents in Sanity CMS? Setting up a full-fledged preview environment for your content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [_type == "post"] { | |
..., | |
author-> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [_type == "post"] { | |
..., | |
"author": * [_id == ("drafts." + ^.author._ref)][0], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [_type == "post"] { | |
..., | |
"author": coalesce( * [_id == ("drafts." + ^.author._ref)][0], author->) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "post" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"docs": * [_type == $type] | |
} | |
{ | |
"drafts": @.docs [_id in path("drafts.**")], | |
"published": @.docs [!(_id in path("drafts.**"))], | |
"coupled": @.docs [!(_id in path("drafts.**"))]{"published": {...}, "draft": ^.docs [_id == "drafts." + ^._id][0]}, | |
} | |
{ | |
"allCoupled": [[email protected], [email protected] [!(@._id in ^.published[]{"_id": ("drafts." + _id)}._id)]{"draft": {...}}], | |
} | |
{ | |
"selected": @.allCoupled[]{ | |
...coalesce(@.draft, @.published) | |
}, | |
}.selected[] { | |
..., | |
"author": coalesce( * [_id == ("drafts." + ^.author._ref)][0], author->) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment