mirror of
https://github.com/alexohneander/alexohneander-astro.git
synced 2025-07-06 18:01:52 +00:00
13 lines
363 B
TypeScript
13 lines
363 B
TypeScript
import type { CollectionEntry } from "astro:content";
|
|
|
|
const getSortedPosts = (posts: CollectionEntry<"blog">[]) =>
|
|
posts
|
|
.filter(({ data }) => !data.draft)
|
|
.sort(
|
|
(a, b) =>
|
|
Math.floor(new Date(b.data.pubDatetime).getTime() / 1000) -
|
|
Math.floor(new Date(a.data.pubDatetime).getTime() / 1000)
|
|
);
|
|
|
|
export default getSortedPosts;
|