Rewrite
This commit is contained in:
commit
d6c414f887
97 changed files with 17956 additions and 0 deletions
18
src/utils/getSortedPosts.ts
Normal file
18
src/utils/getSortedPosts.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import type { CollectionEntry } from "astro:content";
|
||||
import postFilter from "./postFilter";
|
||||
|
||||
const getSortedPosts = (posts: CollectionEntry<"blog">[]) => {
|
||||
return posts
|
||||
.filter(postFilter)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Math.floor(
|
||||
new Date(b.data.modDatetime ?? b.data.pubDatetime).getTime() / 1000
|
||||
) -
|
||||
Math.floor(
|
||||
new Date(a.data.modDatetime ?? a.data.pubDatetime).getTime() / 1000
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export default getSortedPosts;
|
Loading…
Add table
Add a link
Reference in a new issue