Skip to content

Commit

Permalink
fix query to sort posts then limit to 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash Smith committed Sep 12, 2023
1 parent d43e7ad commit e508aaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/sanity.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ImageAsset, Slug } from '@sanity/types'
import groq from 'groq'
import { type SanityClient } from 'next-sanity'

export const postsQuery = groq`*[_type == "post" && defined(slug.current)][0..5] | order(_createdAt desc)`
export const postsQuery = groq`*[_type == "post" && defined(slug.current)] | order(_createdAt desc)[0..5]`
export const allPostsQuery = groq`*[_type == "post" && defined(slug.current)] | order(_createdAt desc)`

export async function getPosts(client: SanityClient): Promise<Post[]> {
Expand Down

0 comments on commit e508aaf

Please sign in to comment.