Skip to content

Commit

Permalink
Merge pull request #248 from JaneliaSciComp/randomize-order-of-projec…
Browse files Browse the repository at this point in the history
…t-cards

style: randomize order of project cards on page refresh
  • Loading branch information
allison-truhlar authored May 23, 2024
2 parents b6f6cc4 + 62563f3 commit d864efb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/pages/projects/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ import ToggleFilterMenuBtn from "../../components/projects/ToggleFilterMenuBtn";
import { extractUniqueTagsObject } from "../../utils/tagManipulation.js";
const baseUrl = import.meta.env.BASE_URL;
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]]; // Swap elements
}
return array;
}
const baseUrl = import.meta.env.BASE_URL;
const pageTitle = "OSSI-supported projects";
const allProjects = await getCollection("projects");
let allProjects = await getCollection("projects");
allProjects = shuffleArray(allProjects);
// uniqueTags is an object where keys = unique tag categories, values = unique tags within a category, both across allProjects. All lowercase.
// used to populate the filter menu
Expand Down

0 comments on commit d864efb

Please sign in to comment.