Skip to content

Commit 95541b2

Browse files
committed
sponsors: randomize order
1 parent b0fd24e commit 95541b2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/sponsors.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::i18n::I18NHelper;
2+
use rand::seq::SliceRandom;
23
use std::error::Error;
34

45
static SPONSORS_YML_PATH: &str = "src/data/sponsors.yml";
@@ -29,16 +30,23 @@ pub(crate) struct RenderSponsor {
2930
pub(crate) fn render_data(lang: &str) -> Vec<RenderSponsor> {
3031
let i18n = I18NHelper::new();
3132

32-
let sponsors = SPONSORS
33+
let mut sponsors = SPONSORS
3334
.iter()
34-
.enumerate()
35-
.map(|(i, s)| RenderSponsor {
35+
.map(|s| RenderSponsor {
3636
name: &s.name,
37-
is_not_first: i != 0,
37+
is_not_first: true, // Will be changed later
3838
logo_path: format!("/static/images/sponsor-logos/{}.png", s.id),
3939
logo_alt_i18n: i18n.lookup(lang, &format!("sponsors-{}-alt", s.id), None),
4040
description_i18n: i18n.lookup(lang, &format!("sponsors-{}", s.id), None),
4141
})
4242
.collect::<Vec<_>>();
43+
44+
sponsors.shuffle(&mut rand::thread_rng());
45+
46+
sponsors
47+
.iter_mut()
48+
.enumerate()
49+
.for_each(|(i, s)| s.is_not_first = i != 0);
50+
4351
sponsors
4452
}

0 commit comments

Comments
 (0)