From 623a157504c9a856287c0270ccf087b2ba7a6bed Mon Sep 17 00:00:00 2001 From: Awstin Date: Tue, 11 Feb 2025 07:06:44 -0500 Subject: [PATCH] No longer ordering links randomly, adding dates to posts --- src/html/root.rs | 5 ++--- templates/blogroll.html | 5 ----- templates/links.html | 4 ---- templates/posts.html | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/html/root.rs b/src/html/root.rs index d93d7da..de0583b 100644 --- a/src/html/root.rs +++ b/src/html/root.rs @@ -6,7 +6,7 @@ use axum::{ routing::{get, post, Router}, Extension, }; -use rand::{seq::SliceRandom, thread_rng, RngCore, SeedableRng}; +use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; use rand_core::OsRng; use sqlx::PgPool; @@ -149,8 +149,7 @@ pub async fn get_links_as_list( Err(_) => Vec::new(), }; - let mut rng = thread_rng(); - links.shuffle(&mut rng); + links.sort_by(|a, b| b.date_added.cmp(&a.date_added)); let list: Vec = links .into_iter() diff --git a/templates/blogroll.html b/templates/blogroll.html index 4d7ca5f..5ecb375 100644 --- a/templates/blogroll.html +++ b/templates/blogroll.html @@ -9,11 +9,6 @@ Places away from the noise of the modern web, without advertisement or trackers. Following links through these is how I spend most of my time online these days.

-

- Links may not be in the same order on each page load. - The list gets randomly shuffled each time to expose new links at the top to visitors. - Just an idea that I had, please contact me if it causes anyone issues. -