Remi Sture
Frontend lead @ Eviny.no
This snippet can be used to fetch current, previous and next articles based on publication date and related tags.
*[_type == $type && slug.current == $slug]{
"current": {
"slug": slug.current, title, publicReleaseDate, "tags": tags[]->tag
},
"previous": *[_type == $type && count((tags[]->tag)[@ in ^.^.tags[]->tag]) > 0 && ^.publicReleaseDate > publicReleaseDate]|order(publicReleaseDate desc)[0]{
"slug": slug.current, title, publicReleaseDate, "tags": tags[]->tag
},
"next": *[_type == $type && count((tags[]->tag)[@ in ^.^.tags[]->tag]) > 0 && ^.publicReleaseDate < publicReleaseDate]|order(publicReleaseDate asc)[0]{
"slug": slug.current, title, publicReleaseDate, "tags": tags[]->tag
},
}|order(publicReleaseDate)[0]{
type: "news_article",
slug: "my-article-slug",
}{
"current": {
"slug": "current-article",
"title": "Current article"
"publicReleaseDate": "2022-09-22",
"tags": ["news"],
},
"next": {
"slug": "next-article",
"title": "Next article"
"publicReleaseDate": "2022-10-11",
"tags": ["news"],
},
"previous": {
"slug": "previous-article",
"title": "Previous article"
"publicReleaseDate": "2022-08-31",
"tags": ["news"],
}
}Inspired by this snippet by Knut Melvær.
Frontend lead @ Eviny.no
Runs Support @ Sanity.io
Support Engineer at Sanity.io
Your block styles will normally look the same in the editor and the styles dropdown. For the times you don't want that, this workaround lets you configure them differently.
Go to Create different block styles for the dropdown and editorSometimes, you just need to migrate a document or two.
Go to Ad hoc document migrationGROQ doesn't yet include a function to match the end of a string, but we can simulate it by splitting our string on our term.
Go to Matching the end of a string in GROQSimplify your Studio experience by hiding deprecated fields when you create new documents.
Go to Hide a deprecated field in new documentsContent operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store