mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-22 07:50:33 +01:00
Fix sorting articles
This commit is contained in:
@@ -42,22 +42,19 @@ export function useSkills() {
|
||||
}
|
||||
|
||||
export function usePosts() {
|
||||
return useAsyncData('content:posts', () => {
|
||||
return queryContent<Post>('writing')
|
||||
.sort({
|
||||
publishedAt: -1,
|
||||
})
|
||||
.find()
|
||||
return useAsyncData('content:posts', async () => {
|
||||
const posts = await queryContent<Post>('writing').find()
|
||||
return posts.sort((a, b) => {
|
||||
return new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function useLatestPost() {
|
||||
return useAsyncData('content:latestPost', () => {
|
||||
return queryContent<Post>('writing')
|
||||
.sort({
|
||||
publishedAt: -1,
|
||||
})
|
||||
.limit(1)
|
||||
.find()
|
||||
return useAsyncData('content:latestPost', async () => {
|
||||
const posts = await queryContent<Post>('writing').find()
|
||||
return posts.sort((a, b) => {
|
||||
return new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime()
|
||||
})[0]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user