From 2cc2b26f8a9320fd26f064529f5790a948ad81b8 Mon Sep 17 00:00:00 2001 From: Michael Uloth Date: Mon, 23 Dec 2024 09:40:41 -0500 Subject: [PATCH] notes: parse modified time before using it for sorting --- src/pages/notes.astro | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pages/notes.astro b/src/pages/notes.astro index fef9b11..da827cf 100644 --- a/src/pages/notes.astro +++ b/src/pages/notes.astro @@ -8,21 +8,16 @@ import { getDrafts } from '../utils/posts' const bookmarks = await getBookmarks() const notes = await getNotes() -const tags = await getAllTagsInNotes() - const drafts = await getDrafts() +const tags = await getAllTagsInNotes() const notesByLastModified = [...bookmarks, ...notes, ...drafts].sort((a, b) => { - if (a.data.lastModified < b.data.lastModified) { - return 1 - } - if (a.data.lastModified > b.data.lastModified) { - return -1 - } - return 0 + const aTime = new Date(a.data.lastModified).getTime() + const bTime = new Date(b.data.lastModified).getTime() + return bTime - aTime }) -const getEmoji = (item: Bookmark | Draft | Writing): string => { +const getLinkEmoji = (item: Bookmark | Draft | Writing): string => { if (item.data.favicon) { return `` } @@ -71,7 +66,7 @@ const getEmoji = (item: Bookmark | Draft | Writing): string => { notesByLastModified.map((item, index) => (
  • - + {item.data.title || item.slug} {item.data.author ? ` (${item.data.author})` : ''}