diff --git a/src/app/Utils.ts b/src/app/Utils.ts index 869323fe..41bdd58e 100644 --- a/src/app/Utils.ts +++ b/src/app/Utils.ts @@ -322,6 +322,16 @@ export async function writeZip(entries: [string, string][]): Promise { return await writer.close() } +export function shuffle(array: T[]) { + let i = array.length + while (i != 0) { + const j = Math.floor(Math.random() * i) + i -= 1; + [array[i], array[j]] = [array[j], array[i]] + } + return array +} + export function computeIfAbsent(map: Map, key: K, getter: (key: K) => V): V { const existing = map.get(key) if (existing) { diff --git a/src/app/pages/Home.tsx b/src/app/pages/Home.tsx index 4ddd5da1..0e135231 100644 --- a/src/app/pages/Home.tsx +++ b/src/app/pages/Home.tsx @@ -1,10 +1,12 @@ import { useMemo } from 'preact/hooks' +import contributors from '../../contributors.json' import { ChangelogEntry, Footer, GeneratorCard, Giscus, GuideCard, ToolCard, ToolGroup } from '../components/index.js' import { useLocale, useTitle } from '../contexts/index.js' import { useAsync } from '../hooks/useAsync.js' import { useMediaQuery } from '../hooks/useMediaQuery.js' import { fetchChangelogs, fetchVersions } from '../services/DataFetcher.js' import { Store } from '../Store.js' +import { shuffle } from '../Utils.js' const MIN_FAVORITES = 2 const MAX_FAVORITES = 5 @@ -35,7 +37,7 @@ export function Home({}: Props) { } - +