File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,36 @@ module.exports = (config) => {
26
26
27
27
config . addCollection ( "sponsorsByLevel" , function ( collectionApi ) {
28
28
const sponsors = collectionApi . getFilteredByGlob ( "src/_content/sponsors/*.md" ) ;
29
-
30
29
const visibleSponsors = sponsors . filter ( sponsor => ! sponsor . data . hidden ) ;
31
-
32
- // TODO: Sort sponsors by date, ascending
33
- return visibleSponsors . reduce ( ( acc , sponsor ) => {
30
+ const levelOrder = [
31
+ "Diamond" ,
32
+ "Platnum" ,
33
+ "Gold" ,
34
+ "Silver" ,
35
+ "Bronze" ,
36
+ "Coffee" ,
37
+ "Opportunity Grant" ,
38
+ "Community" ,
39
+ ] ;
40
+
41
+ const sponsorsByLevel = visibleSponsors . reduce ( ( acc , sponsor ) => {
34
42
const level = sponsor . data . level ;
35
43
if ( ! acc [ level ] ) {
36
44
acc [ level ] = [ ] ;
37
45
}
38
46
acc [ level ] . push ( sponsor ) ;
39
47
return acc ;
40
48
} , { } ) ;
49
+
50
+ // Sort levels based on predefined order
51
+ const sortedSponsorsByLevel = { } ;
52
+ levelOrder . forEach ( level => {
53
+ if ( sponsorsByLevel [ level ] ) {
54
+ sortedSponsorsByLevel [ level ] = sponsorsByLevel [ level ] ;
55
+ }
56
+ } ) ;
57
+
58
+ return sortedSponsorsByLevel ;
41
59
} ) ;
42
60
43
61
/*
You can’t perform that action at this time.
0 commit comments