9 lines
289 B
TypeScript
9 lines
289 B
TypeScript
import { getCollection } from 'astro:content';
|
|
import type { CollectionEntry } from 'astro:content';
|
|
|
|
export function getSortedPosts(posts: CollectionEntry<'blog'>[]) {
|
|
return [...posts].sort(
|
|
(a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime(),
|
|
);
|
|
}
|