mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-30 11:47:53 +01:00
Fix sorting articles
This commit is contained in:
@@ -42,22 +42,19 @@ export function useSkills() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function usePosts() {
|
export function usePosts() {
|
||||||
return useAsyncData('content:posts', () => {
|
return useAsyncData('content:posts', async () => {
|
||||||
return queryContent<Post>('writing')
|
const posts = await queryContent<Post>('writing').find()
|
||||||
.sort({
|
return posts.sort((a, b) => {
|
||||||
publishedAt: -1,
|
return new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime()
|
||||||
})
|
})
|
||||||
.find()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLatestPost() {
|
export function useLatestPost() {
|
||||||
return useAsyncData('content:latestPost', () => {
|
return useAsyncData('content:latestPost', async () => {
|
||||||
return queryContent<Post>('writing')
|
const posts = await queryContent<Post>('writing').find()
|
||||||
.sort({
|
return posts.sort((a, b) => {
|
||||||
publishedAt: -1,
|
return new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime()
|
||||||
})
|
})[0]
|
||||||
.limit(1)
|
|
||||||
.find()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
slug: how-i-start
|
slug: how-i-start
|
||||||
title: 'How do I start programming?'
|
title: 'How do I start programming?'
|
||||||
description: 'Description de test'
|
description: 'Description de test'
|
||||||
publishedAt: '04 September 2023'
|
publishedAt: '01/02/2023'
|
||||||
readingMins: 5
|
readingMins: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
slug: 'new-website'
|
slug: 'new-website'
|
||||||
title: 'New version for my portfolio'
|
title: 'New version for my portfolio'
|
||||||
description: 'Description de test'
|
description: 'Description de test'
|
||||||
publishedAt: '04 September 2023'
|
publishedAt: '09/09/2021'
|
||||||
readingMins: 5
|
readingMins: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user