personal-website/frontend/lib/cms/getMostRecentRevisions.ts
Filipe Medeiros b973949620
not fresh lol
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
2023-12-03 12:26:00 +01:00

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[]`;
}