mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
14 lines
429 B
TypeScript
14 lines
429 B
TypeScript
import type { MarkdownInstance } from "astro";
|
|
import type { Frontmatter } from "../types";
|
|
|
|
const getSortedPosts = (posts: MarkdownInstance<Frontmatter>[]) =>
|
|
posts
|
|
.filter(({ frontmatter }) => !frontmatter.draft)
|
|
.sort(
|
|
(a, b) =>
|
|
Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) -
|
|
Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000)
|
|
);
|
|
|
|
export default getSortedPosts;
|