mirror of
https://github.com/tlsnotary/website.git
synced 2026-01-08 22:38:08 -05:00
Shuffle projects
This commit is contained in:
@@ -3,6 +3,15 @@ import ProjectCard, { ProjectProps } from './ProjectCard';
|
||||
import ProjectData from './Projects.json';
|
||||
import './Projects.css';
|
||||
|
||||
function shuffleFisherYates(array: []): [] {
|
||||
let i = array.length;
|
||||
while (i--) {
|
||||
const ri = Math.floor(Math.random() * i);
|
||||
[array[i], array[ri]] = [array[ri], array[i]];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
function Projects() {
|
||||
let [projects, setProjects] = useState<ProjectProps[]>([]);
|
||||
|
||||
@@ -14,6 +23,8 @@ function Projects() {
|
||||
return (<ProjectCard key={project.name} {...project} />);
|
||||
})
|
||||
|
||||
_projects = shuffleFisherYates(_projects as []);
|
||||
|
||||
return (
|
||||
<div className="Projects">
|
||||
{_projects}
|
||||
|
||||
Reference in New Issue
Block a user