Актуальные события выставлены вперёд списка
This commit is contained in:
parent
d6c3c4990c
commit
828cba41bd
5 changed files with 55 additions and 12 deletions
|
|
@ -22,7 +22,7 @@
|
|||
post,
|
||||
size = BlogCardSize.Both,
|
||||
fullHeight = false
|
||||
}: { post: App.BlogPost; size: BlogCardSize; fullHeight: boolean } = $props();
|
||||
}: { post: App.BlogPost; size?: BlogCardSize; fullHeight?: boolean } = $props();
|
||||
|
||||
const type: App.BlogPostType = post.type ?? 'article';
|
||||
let isPostNew = $state(false);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export function postEventStatus(post: App.BlogPost): EventStatus {
|
|||
export type PostComparer = (a: App.BlogPost, b: App.BlogPost) => number;
|
||||
|
||||
export const sortPostsByPostDate: PostComparer = (a, b) => new Date(b.date!).valueOf() - new Date(a.date!).valueOf();
|
||||
export const sortPostsByPostAndUpdateDate: PostComparer = (a, b) => laterDate(b.date!, b.dateChanged) - laterDate(a.date!, a.dateChanged);
|
||||
|
||||
function laterDate(a: string, ...dates: (string | undefined)[]): number {
|
||||
const dateA = new Date(a).valueOf();
|
||||
|
|
@ -45,8 +46,6 @@ function laterDate(a: string, ...dates: (string | undefined)[]): number {
|
|||
return max;
|
||||
}
|
||||
|
||||
export const sortPostsByPostAndUpdateDate: PostComparer = (a, b) => laterDate(b.date!, b.dateChanged) - laterDate(a.date!, a.dateChanged);
|
||||
|
||||
export async function fetchPostsSorted(postComparer?: PostComparer) {
|
||||
const allPosts = await fetchPosts();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue