Skip to content

Commit dc358cb

Browse files
authored
Merge pull request #269 from css-naked-day/feat/archive-snapshot
feature: Create a list of URLS for participating websites
2 parents a946096 + 1cdd522 commit dc358cb

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

_src/current-year-urls.njk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
permalink: /current-year-urls.txt
3+
---
4+
5+
{%- for url in globals.currentYear | getWebsitesForYear %}
6+
{{- url }}
7+
{% endfor -%}

eleventy.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)