Unlock seamless workflows and faster delivery with our latest releases ā€“ get the details

Ordering articles by views in deskStructure.js for Sanity.io

2 replies
Last updated: Jun 7, 2024
How do i order the childs in my deskStructure.js? I want them to order my articles by views.Been searching for so long now. anyone has an idea_

.child(
S.documentTypeList('article')
.title('Artikler efter sidevisninger')
.filter('_type == "article"')
.ordering({
title: 'Views Descending',
by: [
{field: 'views', direction: 'desc'}
]
})
),
Jun 5, 2024, 1:18 PM
šŸ‘‹ Do you have a
views
field defined in your schema?
Jun 5, 2024, 4:53 PM
Yes i have - I ended up with another solution by putting it in to an orderlist instead tho šŸ™‚orderings: [
{
title: '| Fleste visninger',
name: 'viewsDesc',
by: [
{field: 'views', direction: 'desc'}
]
},
],
Jun 7, 2024, 12:28 PM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?