Skip to content

Commit 984f3ff

Browse files
committed
site-root: randomize the order of the company logos
We don't want to endorse any brand more than any other, so randomize the logos. We use Hugo to randomize the order every build. Also in CSS the order is randomized using a seed and some math. And in JS we set that set every time the page reloads. Signed-off-by: Toon Claes <[email protected]>
1 parent 8d59728 commit 984f3ff

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

assets/sass/front-page.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ $monitor-height: 271px;
199199
}
200200
}
201201

202+
@property --floor {
203+
syntax: '<integer>';
204+
initial-value: 0;
205+
inherits: false;
206+
}
207+
208+
@property --seed {
209+
syntax: '<integer>';
210+
initial-value: #{random(1000)};
211+
inherits: true;
212+
}
213+
202214
#companies-projects {
203215
border-top: solid 1px var(--base-border-color);
204216

@@ -212,6 +224,18 @@ $monitor-height: 271px;
212224

213225
li {
214226
margin: 1em 2em;
227+
228+
$num: 11;
229+
$prime: 97;
230+
231+
@for $i from 1 through $num {
232+
&:nth-child(#{$i}) {
233+
--prod: calc(var(--seed) * #{$i} * #{$prime});
234+
--floor: calc((var(--prod) / #{$num}) - 0.5);
235+
236+
order: calc(var(--prod) - (#{$num} * var(--floor)));
237+
}
238+
}
215239
}
216240

217241
a {

layouts/partials/site-root.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,19 @@ <h3>Community</h3>
6060
<section id="companies-projects">
6161
<h3 class="text-center">Products providing Git hosting</h3>
6262
<ul>
63-
<li><a href="https://gitlab.com">{{ partial "company-svg" "company-project-logos/gitlab" }}</a></li>
64-
<li><a href="https://github.com">{{ partial "company-svg" "company-project-logos/github" }}</a></li>
65-
<li><a href="https://forgejo.org">{{ partial "company-svg" "company-project-logos/forgejo" }}</a></li>
66-
<li><a href="https://codeberg.org">{{ partial "company-svg" "company-project-logos/codeberg" }}</a></li>
67-
<li><a href="https://sourcehut.org">{{ partial "company-svg" "company-project-logos/sourcehut" }}</a></li>
68-
<li><a href="https://gitea.com">{{ partial "company-svg" "company-project-logos/gitea" }}</a></li>
63+
{{ $m := slice
64+
(dict "name" "gitlab" "url" "https://gitlab.com")
65+
(dict "name" "github" "url" "https://github.com")
66+
(dict "name" "forgejo" "url" "https://forgejo.org")
67+
(dict "name" "codeberg" "url" "https://codeberg.org")
68+
(dict "name" "sourcehut" "url" "https://sourcehut.org")
69+
(dict "name" "gitea" "url" "https://gitea.com")
70+
}}
71+
{{ range shuffle $m }}
72+
<li><a href="{{ .url }}">{{ partial "company-svg" (printf "company-project-logos/%s" .name) }}</a></li>
73+
{{ end }}
6974
</ul>
75+
<script type="text/javascript">
76+
document.getElementById("companies-projects").style.setProperty("--seed", Math.floor(Math.random() * 1000));
77+
</script>
7078
</section>

0 commit comments

Comments
 (0)