summaryrefslogtreecommitdiff
path: root/website/src/components/LinksFeed.astro
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2024-07-16 14:48:05 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2024-07-16 14:48:05 +0100
commit7c4b001d599da3ba8d83fc8205a4530f5063dd82 (patch)
treeadc3081574be6471d467344ec08fdc0e2c52c15e /website/src/components/LinksFeed.astro
parentc32b100ba00d720621336d5439c753f51e408f56 (diff)
Corrects and simplifies ordering of feed items in blog and links
Diffstat (limited to 'website/src/components/LinksFeed.astro')
-rw-r--r--website/src/components/LinksFeed.astro17
1 files changed, 3 insertions, 14 deletions
diff --git a/website/src/components/LinksFeed.astro b/website/src/components/LinksFeed.astro
index fbbf9f4..9e7e788 100644
--- a/website/src/components/LinksFeed.astro
+++ b/website/src/components/LinksFeed.astro
@@ -29,20 +29,9 @@ function matchesYear(year: string) {
}
function sortByDateAddedDescending(link1: (typeof links)[number], link2: (typeof links)[number]) {
- const year1 = Number.parseInt(link1.isoDateAdded.slice(0, 4));
- const year2 = Number.parseInt(link2.isoDateAdded.slice(0, 4));
- const month1 = Number.parseInt(link1.isoDateAdded.slice(5, 7));
- const month2 = Number.parseInt(link2.isoDateAdded.slice(5, 7));
- const day1 = Number.parseInt(link1.isoDateAdded.slice(8, 10));
- const day2 = Number.parseInt(link2.isoDateAdded.slice(8, 10));
-
- if (year1 !== year2) {
- return year2 - year1;
- } else if (month1 !== month2) {
- return month2 - month1;
- } else {
- return day2 - day1;
- }
+ const date1 = new Date(link1.isoDateAdded).getTime();
+ const date2 = new Date(link2.isoDateAdded).getTime();
+ return date2 - date1;
}
const canonicalLinksUrl = new URL('links', Astro.site)