No longer ordering links randomly, adding dates to posts
This commit is contained in:
parent
34275031b5
commit
623a157504
4 changed files with 3 additions and 13 deletions
|
|
@ -6,7 +6,7 @@ use axum::{
|
||||||
routing::{get, post, Router},
|
routing::{get, post, Router},
|
||||||
Extension,
|
Extension,
|
||||||
};
|
};
|
||||||
use rand::{seq::SliceRandom, thread_rng, RngCore, SeedableRng};
|
use rand::{RngCore, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
use rand_core::OsRng;
|
use rand_core::OsRng;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
@ -149,8 +149,7 @@ pub async fn get_links_as_list(
|
||||||
Err(_) => Vec::new(),
|
Err(_) => Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
links.sort_by(|a, b| b.date_added.cmp(&a.date_added));
|
||||||
links.shuffle(&mut rng);
|
|
||||||
|
|
||||||
let list: Vec<Link> = links
|
let list: Vec<Link> = links
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,6 @@
|
||||||
Places away from the noise of the modern web, without advertisement or trackers.
|
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.
|
Following links through these is how I spend most of my time online these days.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
|
||||||
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 <a href="/contact">contact me</a> if it causes anyone issues.
|
|
||||||
</p>
|
|
||||||
<ul class="no-bul">
|
<ul class="no-bul">
|
||||||
{% for blog in blogs %}
|
{% for blog in blogs %}
|
||||||
<li><a href={{blog.url}}>{{blog.title}}</a>
|
<li><a href={{blog.url}}>{{blog.title}}</a>
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,6 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Links</h2>
|
<h2>Links</h2>
|
||||||
<p>
|
|
||||||
A collection of links to interesting posts that I have found.
|
|
||||||
In a random order to shuffle what links are at the top.
|
|
||||||
</p>
|
|
||||||
<ul class="no-bul">
|
<ul class="no-bul">
|
||||||
{% for article in articles %}
|
{% for article in articles %}
|
||||||
<li><a href={{article.url}}>{{article.title}}</a>
|
<li><a href={{article.url}}>{{article.title}}</a>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<ul class="no-bul">
|
<ul class="no-bul">
|
||||||
{% for article in articles %}
|
{% for article in articles %}
|
||||||
<li><a href="/posts/{{article.reference}}">{{article.title}}</a></li>
|
<li><a href="/posts/{{article.reference}}">{{article.date}} {{article.title}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue