File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,21 @@ module.exports = function(eleventyConfig) {
2323 }
2424 } ) ;
2525
26- // 3. Collection setup
27- eleventyConfig . addCollection ( "people" , function ( collectionApi ) {
28- return collectionApi . getFilteredByGlob ( "src/users/*.yaml" ) ;
26+ // 2. The Randomized Collection
27+ eleventyConfig . addCollection ( "randomPeople" , function ( collectionApi ) {
28+ // Grab all yaml files from the users folder
29+ const people = collectionApi . getFilteredByGlob ( "src/users/*.yaml" ) ;
30+
31+ // Create a copy of the array to avoid mutating the original global collection
32+ let shuffled = [ ...people ] ;
33+
34+ // Fisher-Yates Shuffle
35+ for ( let i = shuffled . length - 1 ; i > 0 ; i -- ) {
36+ const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ;
37+ [ shuffled [ i ] , shuffled [ j ] ] = [ shuffled [ j ] , shuffled [ i ] ] ;
38+ }
39+
40+ return shuffled ;
2941 } ) ;
3042
3143 return {
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ layout: false
5454
5555 <main class =" max-w-7xl mx-auto px-4 pb-24" >
5656 <div class =" grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8" >
57- {% for person in collections .people %}
57+ {% for person in collections .randomPeople %}
5858 <div class =" user-card group card-glow bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-800 overflow-hidden flex flex-col hover:-translate-y-2 hover:border-indigo-400 dark:hover:border-indigo-500 scroll-mt-32" >
5959
6060 <div class =" p-8" >
You can’t perform that action at this time.
0 commit comments