|
1 | 1 | {{ define "main" }}
|
2 | 2 | {{ partial "page-header" . }}
|
3 | 3 | <section class="section pt-6 contributors-list-section">
|
4 |
| - |
5 | 4 | <div class="container">
|
6 | 5 |
|
7 | 6 | <div class="mt-6 mb-12">
|
|
14 | 13 | ) }}
|
15 | 14 | </div>
|
16 | 15 |
|
17 |
| - |
18 |
| - {{/* 1. Get all contributor profile pages, sorted by title (name) */}} |
19 |
| - {{ $allContributorProfiles := where site.RegularPages "Section" "contributors" }} |
20 |
| - |
21 |
| - {{/* 2. Collect all relevant content pages that can be authored and have a date */}} |
22 |
| - {{ $relevantContent := slice }} |
23 |
| - {{ $contentSectionsToScan := slice "blog" "workshops" "student-talks" }} |
24 |
| - {{ $contentTypesToScan := slice "hacking-hours" "initiatives" }} |
25 |
| - |
26 |
| - {{ range site.RegularPages }} |
27 |
| - {{ if and .Date (not .Date.IsZero) .Params.author }} |
28 |
| - {{ $isRelevantPage := false }} |
29 |
| - {{ if in $contentSectionsToScan .Section }}{{ $isRelevantPage = true }}{{ end }} |
30 |
| - {{ if in $contentTypesToScan .Type }}{{ $isRelevantPage = true }}{{ end }} |
31 |
| - |
32 |
| - {{ if $isRelevantPage }} |
33 |
| - {{ $relevantContent = $relevantContent | append . }} |
34 |
| - {{ end }} |
35 |
| - {{ end }} |
36 |
| - {{ end }} |
37 |
| - |
38 |
| - {{/* 3. Determine all unique contribution years from relevant content dates */}} |
39 |
| - {{ $allYearsSlice := slice }} |
40 |
| - {{ range $relevantContent }} |
41 |
| - {{ $year := .Date.Format "2006" }} |
42 |
| - {{ $allYearsSlice = $allYearsSlice | append $year }} |
43 |
| - {{ $dateEndParamValue := "" }} |
44 |
| - {{ if isset .Params "date_end" }} |
45 |
| - {{ $dateEndParamValue = index .Params "date_end" }} {{/* Corrected: index .Params "key" */}} |
46 |
| - {{ else if isset .Params "date-end" }} |
47 |
| - {{ $dateEndParamValue = index .Params "date-end" }} {{/* Corrected: index .Params "key" */}} |
48 |
| - {{ end }} |
49 |
| - {{ if and (eq (lower .Type) "initiatives") .Params.legacy $dateEndParamValue }} |
50 |
| - {{ $startYear := .Date.Format "2006" | int }} |
51 |
| - {{ with $dateEndParamValue }} |
52 |
| - {{ $parsedEndDate := time.AsTime . }} |
53 |
| - {{ if $parsedEndDate.IsZero }} |
54 |
| - {{ warnf "Initiative %s has invalid date-end value: %s" $.File.Path . }} |
55 |
| - {{ else }} |
56 |
| - {{ $endYear := $parsedEndDate.Format "2006" | int }} |
57 |
| - {{ range seq $startYear $endYear }} |
58 |
| - {{ $allYearsSlice = $allYearsSlice | append (string .) }} |
59 |
| - {{ end }} |
60 |
| - {{ end }} |
61 |
| - {{ end }} |
62 |
| - {{ end }} |
63 |
| - {{ end }} |
64 |
| - {{ $uniqueYearsSorted := $allYearsSlice | uniq | sort | collections.Reverse }} |
65 |
| - |
66 |
| - {{/* 4. Define contribution types (excluding initiatives here as they are handled separately) */}} |
67 |
| - {{ $contributionSectionDefs := slice |
68 |
| - (dict "id" "blog" "plural" "Blog Posts" "matchField" "Section") |
69 |
| - (dict "id" "workshops" "plural" "Workshops" "matchField" "Section") |
70 |
| - (dict "id" "student-talks" "plural" "Student Talks" "matchField" "Section") |
71 |
| - (dict "id" "hacking-hours" "plural" "Hacking Hours" "matchField" "Type") |
72 |
| - }} |
73 |
| - |
74 |
| - {{ range $year_str := $uniqueYearsSorted }} |
75 |
| - {{ $current_loop_year := int $year_str }} |
| 16 | + {{- .Scratch.Set "contributorContent" (dict) -}} |
| 17 | + {{- $contentSectionsToScan := slice "blog" "workshops" "student-talks" -}} |
| 18 | + {{- $contentTypesToScan := slice "hacking-hours" "initiatives" -}} |
| 19 | + |
| 20 | + {{- range where site.RegularPages "Params.author" "!=" nil -}} |
| 21 | + {{- $page := . -}} |
| 22 | + {{- $isRelevantPage := or (in $contentSectionsToScan $page.Section) (in $contentTypesToScan $page.Type) -}} |
| 23 | + {{- if and $isRelevantPage $page.Date (not $page.Date.IsZero) -}} |
| 24 | + {{- $authors := cond (reflect.IsSlice $page.Params.author) $page.Params.author (slice $page.Params.author) -}} |
| 25 | + {{- range $authorName := $authors -}} |
| 26 | + {{- $slug := $authorName | anchorize -}} |
| 27 | + {{- $currentMap := $.Scratch.Get "contributorContent" -}} |
| 28 | + {{- $existingContributions := index $currentMap $slug | default (slice) -}} |
| 29 | + {{- $newContributions := $existingContributions | append $page -}} |
| 30 | + {{- $.Scratch.SetInMap "contributorContent" $slug $newContributions -}} |
| 31 | + {{- end -}} |
| 32 | + {{- end -}} |
| 33 | + {{- end -}} |
| 34 | + |
| 35 | + {{- $allContributorProfiles := where site.RegularPages "Section" "contributors" -}} |
| 36 | + {{- $contributorContentMap := .Scratch.Get "contributorContent" -}} |
| 37 | + |
| 38 | + {{- $allYearsSlice := slice -}} |
| 39 | + {{- range $slug, $pages := $contributorContentMap -}} |
| 40 | + {{- range $page := $pages -}} |
| 41 | + {{- $allYearsSlice = $allYearsSlice | append ($page.Date.Format "2006") -}} |
| 42 | + {{- if and (eq (lower $page.Type) "initiatives") $page.Params.legacy -}} |
| 43 | + {{- $dateEndVal := "" -}} |
| 44 | + {{- if isset $page.Params "date_end" }}{{ $dateEndVal = $page.Params.date_end }}{{ else if isset $page.Params "date-end" }}{{ $dateEndVal = index $page.Params "date-end" }}{{ end -}} |
| 45 | + {{- with $dateEndVal -}} |
| 46 | + {{- with time.AsTime . -}} |
| 47 | + {{- range seq ($page.Date.Format "2006" | int) .Year -}} |
| 48 | + {{- $allYearsSlice = $allYearsSlice | append (string .) -}} |
| 49 | + {{- end -}} |
| 50 | + {{- end -}} |
| 51 | + {{- end -}} |
| 52 | + {{- end -}} |
| 53 | + {{- end -}} |
| 54 | + {{- end -}} |
| 55 | + {{- $uniqueYearsSorted := $allYearsSlice | uniq | sort | collections.Reverse -}} |
| 56 | + |
| 57 | + {{- $contributionSectionDefs := slice |
| 58 | + (dict "id" "blog" "plural" "Blog Posts" "matchField" "Section") |
| 59 | + (dict "id" "workshops" "plural" "Workshops" "matchField" "Section") |
| 60 | + (dict "id" "student-talks" "plural" "Student Talks" "matchField" "Type") |
| 61 | + (dict "id" "hacking-hours" "plural" "Hacking Hours" "matchField" "Type") |
| 62 | + -}} |
| 63 | + |
| 64 | + {{- range $year_str := $uniqueYearsSorted -}} |
| 65 | + {{- $current_loop_year := int $year_str -}} |
76 | 66 | <div class="year-section mb-6">
|
77 | 67 | <h2 class="text-3xl text-center font-bold mb-10 pb-2">{{ $year_str }} Contributors</h2>
|
78 |
| - |
79 |
| - {{ $contributorsInThisYear := slice }} |
80 |
| - |
81 |
| - {{ range $contributorProfilePage := $allContributorProfiles }} |
82 |
| - {{ $contributorName := $contributorProfilePage.Title }} |
83 |
| - {{ $contributionsThisYearBadges := dict }} |
84 |
| - {{ $initiativesLedThisYear := slice }} |
85 |
| - {{ $totalContributionsThisYear := 0 }} |
86 |
| - |
87 |
| - {{ range $contentPage := $relevantContent }} |
88 |
| - {{ $isAuthorOfThisContent := false }} |
89 |
| - {{ if $contentPage.Params.author }} |
90 |
| - {{ if reflect.IsSlice $contentPage.Params.author }} |
91 |
| - {{ if in $contentPage.Params.author $contributorName }}{{ $isAuthorOfThisContent = true }}{{ end }} |
92 |
| - {{ else }} |
93 |
| - {{ if eq $contentPage.Params.author $contributorName }}{{ $isAuthorOfThisContent = true }}{{ end }} |
94 |
| - {{ end }} |
95 |
| - {{ end }} |
96 |
| - |
97 |
| - {{ if $isAuthorOfThisContent }} |
98 |
| - {{ $contentItemStartYear := $contentPage.Date.Format "2006" | int }} |
99 |
| - {{ $isActualInitiativePage := eq (lower $contentPage.Type) "initiatives" }} |
100 |
| - {{ $isLegacyInitiative := $contentPage.Params.legacy | default false }} |
101 |
| - |
102 |
| - {{ $countThisItemForThisYearLoop := false }} |
103 |
| - |
104 |
| - {{ if $isActualInitiativePage }} |
105 |
| - {{ $dateEndParamValue := "" }} |
106 |
| - {{ if isset $contentPage.Params "date_end" }} |
107 |
| - {{ $dateEndParamValue = index $contentPage.Params "date_end" }} {{/* Corrected: index .Params "key" */}} |
108 |
| - {{ else if isset $contentPage.Params "date-end" }} |
109 |
| - {{ $dateEndParamValue = index $contentPage.Params "date-end" }} {{/* Corrected: index .Params "key" */}} |
110 |
| - {{ end }} |
111 |
| - |
112 |
| - {{ if $isLegacyInitiative }} |
113 |
| - {{ if $dateEndParamValue }} |
114 |
| - {{ with $dateEndParamValue }} |
115 |
| - {{ $parsedEndDate := time.AsTime . }} |
116 |
| - {{ if $parsedEndDate.IsZero }} |
117 |
| - {{ warnf "Initiative %s has invalid date-end value: %s" $contentPage.File.Path . }} |
118 |
| - {{/* Fallback to start year only if end date is invalid */}} |
119 |
| - {{ if eq $current_loop_year $contentItemStartYear }}{{ $countThisItemForThisYearLoop = true }}{{ end }} |
120 |
| - {{ else }} |
121 |
| - {{ $contentItemEndYear := $parsedEndDate.Format "2006" | int }} |
122 |
| - {{ if and (ge $current_loop_year $contentItemStartYear) (le $current_loop_year $contentItemEndYear) }} |
123 |
| - {{ $countThisItemForThisYearLoop = true }} |
124 |
| - {{ end }} |
125 |
| - {{ end }} |
126 |
| - {{ end }} |
127 |
| - {{ else }} {{/* No end date for legacy, count only for start year */}} |
128 |
| - {{ if eq $current_loop_year $contentItemStartYear }}{{ $countThisItemForThisYearLoop = true }}{{ end }} |
129 |
| - {{ end }} |
130 |
| - {{ else }} {{/* Ongoing initiative */}} |
131 |
| - {{ if ge $current_loop_year $contentItemStartYear }}{{ $countThisItemForThisYearLoop = true }}{{ end }} |
132 |
| - {{ end }} |
133 |
| - {{ else }} {{/* Not an initiative page */}} |
134 |
| - {{ if eq $current_loop_year $contentItemStartYear }}{{ $countThisItemForThisYearLoop = true }}{{ end }} |
135 |
| - {{ end }} |
136 |
| - |
137 |
| - |
138 |
| - {{ if $countThisItemForThisYearLoop }} |
139 |
| - {{ if $isActualInitiativePage }} |
140 |
| - {{ $initiativesLedThisYear = $initiativesLedThisYear | append $contentPage }} |
141 |
| - {{ else }} |
142 |
| - {{ range $sectionDef := $contributionSectionDefs }} |
143 |
| - {{ $sectionID := $sectionDef.id }} |
144 |
| - {{ $isMatchForBadge := false }} |
145 |
| - {{ if eq $sectionDef.matchField "Type" }} |
146 |
| - {{ if eq (lower $contentPage.Type) (lower $sectionID) }}{{ $isMatchForBadge = true }}{{ end }} |
147 |
| - {{ else if eq $sectionDef.matchField "Section" }} |
148 |
| - {{ if eq (lower $contentPage.Section) (lower $sectionID) }}{{ $isMatchForBadge = true }}{{ end }} |
149 |
| - {{ end }} |
150 |
| - |
151 |
| - {{ if $isMatchForBadge }} |
152 |
| - {{ $currentCount := index $contributionsThisYearBadges $sectionDef.plural | default 0 }} |
153 |
| - {{ $contributionsThisYearBadges = merge $contributionsThisYearBadges (dict $sectionDef.plural (add $currentCount 1)) }} |
154 |
| - {{ end }} |
155 |
| - {{ end }} |
156 |
| - {{ end }} |
157 |
| - {{ $totalContributionsThisYear = add $totalContributionsThisYear 1 }} |
158 |
| - {{ end }} |
159 |
| - {{ end }} |
160 |
| - {{ end }} |
161 |
| - |
162 |
| - {{ if gt $totalContributionsThisYear 0 }} |
163 |
| - {{ $has_initiatives_this_year_flag := gt (len $initiativesLedThisYear) 0 }} |
164 |
| - {{ $contributorsInThisYear = $contributorsInThisYear | append (dict |
165 |
| - "profile" $contributorProfilePage |
166 |
| - "badges" $contributionsThisYearBadges |
167 |
| - "initiatives_led" $initiativesLedThisYear |
168 |
| - "has_initiatives_this_year" $has_initiatives_this_year_flag |
169 |
| - "total" $totalContributionsThisYear |
170 |
| - ) }} |
171 |
| - {{ end }} |
172 |
| - {{ end }} |
173 |
| - |
174 |
| - {{ $sortedContributorsInThisYear := sort $contributorsInThisYear "has_initiatives_this_year" "desc" "total" "desc" }} |
175 |
| - |
176 |
| - {{ if $sortedContributorsInThisYear }} |
| 68 | + {{- $contributorsInThisYear := slice -}} |
| 69 | + {{- range $contributorProfilePage := $allContributorProfiles -}} |
| 70 | + {{- $contributorName := $contributorProfilePage.Title -}} |
| 71 | + {{- $slug := $contributorName | anchorize -}} |
| 72 | + {{- with index $contributorContentMap $slug -}} |
| 73 | + {{- $authoredPages := . -}} |
| 74 | + {{- $contributionsThisYearBadges := dict -}} |
| 75 | + {{- $initiativesLedThisYear := slice -}} |
| 76 | + {{- range $contentPage := $authoredPages -}} |
| 77 | + {{- $contentItemStartYear := $contentPage.Date.Format "2006" | int -}} |
| 78 | + {{- $isActualInitiativePage := eq (lower $contentPage.Type) "initiatives" -}} |
| 79 | + {{- $countThisItemForThisYearLoop := false -}} |
| 80 | + {{- if $isActualInitiativePage -}} |
| 81 | + {{- if $contentPage.Params.legacy -}} |
| 82 | + {{- $endYear := $contentItemStartYear -}} |
| 83 | + {{- $dateEndVal := "" -}} |
| 84 | + {{- if isset $contentPage.Params "date_end" }}{{ $dateEndVal = $contentPage.Params.date_end }}{{ else if isset $contentPage.Params "date-end" }}{{ $dateEndVal = index $contentPage.Params "date-end" }}{{ end -}} |
| 85 | + {{- with $dateEndVal -}}{{- with time.AsTime . -}}{{- $endYear = .Year -}}{{- end -}}{{- end -}} |
| 86 | + {{- if and (ge $current_loop_year $contentItemStartYear) (le $current_loop_year $endYear) -}} |
| 87 | + {{- $countThisItemForThisYearLoop = true -}} |
| 88 | + {{- end -}} |
| 89 | + {{- else -}} |
| 90 | + {{- if ge $current_loop_year $contentItemStartYear -}}{{- $countThisItemForThisYearLoop = true -}}{{- end -}} |
| 91 | + {{- end -}} |
| 92 | + {{- else -}} |
| 93 | + {{- if eq $current_loop_year $contentItemStartYear -}}{{- $countThisItemForThisYearLoop = true -}}{{- end -}} |
| 94 | + {{- end -}} |
| 95 | + {{- if $countThisItemForThisYearLoop -}} |
| 96 | + {{- if $isActualInitiativePage -}} |
| 97 | + {{- $initiativesLedThisYear = $initiativesLedThisYear | append $contentPage -}} |
| 98 | + {{- else -}} |
| 99 | + {{- range $def := $contributionSectionDefs -}} |
| 100 | + {{- $matchValue := cond (eq $def.matchField "Section") $contentPage.Section $contentPage.Type -}} |
| 101 | + {{- if eq (lower $matchValue) (lower $def.id) -}} |
| 102 | + {{- $currentCount := index $contributionsThisYearBadges $def.plural | default 0 -}} |
| 103 | + {{- $contributionsThisYearBadges = merge $contributionsThisYearBadges (dict $def.plural (add $currentCount 1)) -}} |
| 104 | + {{- end -}} |
| 105 | + {{- end -}} |
| 106 | + {{- end -}} |
| 107 | + {{- end -}} |
| 108 | + {{- end -}} |
| 109 | + |
| 110 | + {{- $badgeCount := 0 -}} |
| 111 | + {{- range $key, $value := $contributionsThisYearBadges -}} |
| 112 | + {{- $badgeCount = add $badgeCount $value -}} |
| 113 | + {{- end -}} |
| 114 | + {{- $totalContributionsThisYear := add (len $initiativesLedThisYear) $badgeCount -}} |
| 115 | + |
| 116 | + {{- if gt $totalContributionsThisYear 0 -}} |
| 117 | + {{- $contributorsInThisYear = $contributorsInThisYear | append (dict |
| 118 | + "profile" $contributorProfilePage |
| 119 | + "badges" $contributionsThisYearBadges |
| 120 | + "initiatives_led" $initiativesLedThisYear |
| 121 | + "has_initiatives_this_year" (gt (len $initiativesLedThisYear) 0) |
| 122 | + "total" $totalContributionsThisYear |
| 123 | + ) |
| 124 | + -}} |
| 125 | + {{- end -}} |
| 126 | + {{- end -}} |
| 127 | + {{- end -}} |
| 128 | + |
| 129 | + {{- $sortedContributorsInThisYear := sort $contributorsInThisYear "has_initiatives_this_year" "desc" "total" "desc" -}} |
| 130 | + {{- if $sortedContributorsInThisYear -}} |
177 | 131 | <div class="row">
|
178 |
| - {{ range $contribData := $sortedContributorsInThisYear }} |
| 132 | + {{- range $contribData := $sortedContributorsInThisYear -}} |
179 | 133 | <div class="md:col-6 lg:col-4 mb-8 flex flex-col">
|
180 |
| - {{ partial "components/author-card" (dict |
181 |
| - "context" $contribData.profile |
182 |
| - "variant" "compact" |
183 |
| - "contribution_badges" $contribData.badges |
184 |
| - "initiatives_led" $contribData.initiatives_led |
185 |
| - "total_contributions" $contribData.total |
186 |
| - ) |
187 |
| - }} |
| 134 | + {{- partial "components/author-card.html" (dict |
| 135 | + "context" $contribData.profile |
| 136 | + "variant" "compact" |
| 137 | + "contribution_badges" $contribData.badges |
| 138 | + "initiatives_led" $contribData.initiatives_led |
| 139 | + "total_contributions" $contribData.total |
| 140 | + ) |
| 141 | + -}} |
188 | 142 | </div>
|
189 |
| - {{ end }} |
| 143 | + {{- end -}} |
190 | 144 | </div>
|
191 |
| - {{ else }} |
| 145 | + {{- else -}} |
192 | 146 | <p class="italic text-gray-600 dark:text-darkmode-light/80">No contributors with categorized content found for {{ $year_str }}.</p>
|
193 |
| - {{ end }} |
| 147 | + {{- end -}} |
194 | 148 | </div>
|
195 |
| - {{ end }} |
196 |
| -{{ if not $uniqueYearsSorted }} |
197 |
| -<p class="text-center text-xl">No contributions found with yearly data.</p> |
198 |
| -{{ end }} |
199 |
| - |
200 |
| -</div> |
| 149 | + {{- end -}} |
| 150 | + </div> |
201 | 151 | </section>
|
202 | 152 | {{ end }}
|
0 commit comments