Skip to content

Commit

Permalink
fix: safari 展示文章顺序错误
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9804 committed Nov 27, 2024
1 parent 959ae60 commit 3cf4ea9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/.vitepress/theme/utils/usePostData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export function defaultFilter(post: Post) {
export const postData = {
async getAllPosts(filter?: (post: Post) => boolean) {
const posts = (await usePosts) as Post[];
const sortedPosts = posts.sort((a, b) => b.createdAt - a.createdAt);
return filter ? sortedPosts.filter(filter) : sortedPosts;
const filteredPosts = filter ? posts.filter(filter) : posts;
return filteredPosts.sort(
(a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
);
},

async getCreatedAt(currentPathWithoutBase: string) {
Expand Down

0 comments on commit 3cf4ea9

Please sign in to comment.