this repo has no description
1import { Post } from "@/modules/post/entities/Post"
2import { computed } from "vue"
3
4const byMostRecentFirst = (a: Post, b: Post) => {
5 if (!b.date) {
6 return 1
7 }
8
9 if (!a.date) {
10 return 1
11 }
12
13 return a.date <= b.date ? 1 : -1
14}
15
16export const usePosts = () => {
17 const posts = useDocuments<Post>("@/pages/posts")
18
19 return computed(() => posts.value.sort(byMostRecentFirst))
20}