24 lines
515 B
TypeScript
24 lines
515 B
TypeScript
import groq from 'groq';
|
|
|
|
export default function getMostRecentRevisions(filter: string) {
|
|
return groq`
|
|
{
|
|
"drafts": select(
|
|
!$live => *[
|
|
${filter} &&
|
|
_id in path("drafts.**")
|
|
],
|
|
$live => []
|
|
),
|
|
"published": *[
|
|
${filter} &&
|
|
!(_id in path("drafts.**"))
|
|
],
|
|
}
|
|
{
|
|
"current": published[
|
|
!("drafts." + @._id in ^.drafts[]._id)
|
|
] + drafts
|
|
}.current[]`;
|
|
}
|