File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ permalink: /current-year-urls.txt
3+ ---
4+
5+ {%- for url in globals .currentYear | getWebsitesForYear %}
6+ {{- url }}
7+ {% endfor -%}
Original file line number Diff line number Diff line change @@ -74,6 +74,27 @@ export default function (eleventyConfig) {
7474 . sort ( ( a , b ) => a . participant > b . participant ? 1 : - 1 ) ;
7575 } ) ;
7676
77+ /**
78+ * Get all websites for the requested year.
79+ *
80+ * @param {string) year - target year
81+ * @return {array } URLs for websites participating for this year
82+ */
83+ eleventyConfig . addFilter ( 'getWebsitesForYear' , function ( year ) {
84+ const participants = this . ctx . participants ;
85+ const websitesForYear = [ ] ;
86+
87+ for ( const participant in participants ) {
88+ participants [ participant ] . websites . forEach ( website => {
89+ if ( website . years . includes ( year ) ) {
90+ websitesForYear . push ( website . url ) ;
91+ }
92+ } ) ;
93+ } ;
94+
95+ return websitesForYear ;
96+ } ) ;
97+
7798 // Shortcodes
7899 // ===============================================================================================
79100
You can’t perform that action at this time.
0 commit comments