File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed
components/Common/Partners Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,14 @@ const PartnersLogoList: FC<PartnersLogoListProps> = ({
2020} ) => {
2121 const initialRenderer = useRef ( true ) ;
2222
23- const [ seedList , setSeedList ] = useState < Array < Partners > > (
24- LOGO_PARTNERS . slice ( 0 , maxLength )
25- ) ;
23+ const [ seedList , setSeedList ] = useState < Array < Partners > > ( ( ) => {
24+ if ( maxLength === null ) {
25+ return LOGO_PARTNERS . filter (
26+ partner => ! categories || partner . categories . includes ( categories )
27+ ) ;
28+ }
29+ return LOGO_PARTNERS . slice ( 0 , maxLength ) ;
30+ } ) ;
2631
2732 useEffect ( ( ) => {
2833 // We intentionally render the initial default "mock" list of sponsors
Original file line number Diff line number Diff line change 11import type { PartnerCategory , Partners } from '#site/types/partners.js' ;
22
33// TODO: Implement no random list
4- // TODO: Implement no limit items
4+ // TODO: Implement no importance of partner
55function randomPartnerList (
66 partners : Array < Partners > ,
77 pick = 4 ,
@@ -28,12 +28,15 @@ function randomPartnerList(
2828 const rng = mulberry32 ( seed ) ;
2929
3030 // Create a copy of the array to avoid modifying the original
31- const shuffled = partners
31+ let shuffled = [ ... partners ]
3232 . filter ( partner => ! category || partner . categories . includes ( category ) )
33- . slice ( )
3433 . sort ( ( ) => rng ( ) - 0.5 ) ;
3534
36- return shuffled . slice ( 0 , pick ) ;
35+ if ( pick !== null ) {
36+ shuffled = shuffled . slice ( 0 , pick ) ;
37+ }
38+
39+ return shuffled ;
3740}
3841
3942// This function returns a random list of partners based on a fixed time seed
Original file line number Diff line number Diff line change @@ -11,19 +11,19 @@ Importance of partners and their role and explains our partner categories (Ecosy
1111
1212Projects with their logo, name, tier, the description and a CTA button
1313
14- <PartnersLogoList categories = " infrastructure" />
14+ <PartnersLogoList categories = " infrastructure" maxLength = { null } />
1515
1616## Security
1717
1818Projects with their logo, name, tier, the description and a CTA button
1919
20- <PartnersLogoList categories = " security" />
20+ <PartnersLogoList categories = " security" maxLength = { null } />
2121
2222## Ecosystem Sustainability Program (ESP)
2323
2424Projects with their logo, name, tier, the description and a CTA button
2525
26- <PartnersLogoList categories = " esp" />
26+ <PartnersLogoList categories = " esp" maxLength = { null } />
2727
2828## Backers (Open Collective and GitHub Sponsors)
2929
You can’t perform that action at this time.
0 commit comments