Skip to content

Commit 4a1c8bc

Browse files
committed
Opt-out of country lookup by specifying the data in the YAML file.
1 parent c4d0f3f commit 4a1c8bc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/site/_data/community.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- name: Boston
1010
link: https://www.meetup.com/Jamstack-Boston/
1111
feed: https://api.meetup.com/Jamstack-Boston/events
12+
country: United States of America
1213

1314
- name: Porto
1415
link: https://www.meetup.com/Jamstack-Porto/

src/site/_data/eleventyComputed.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ module.exports = {
2323
community: async function(data) {
2424
let community = data.community.filter(e => true);
2525
for(let meetup of community) {
26+
// skip if populated in the YAML file
27+
if(meetup.country) {
28+
continue;
29+
}
30+
2631
// sry for await in loop
2732
let countryCode = await getCountryCode(meetup.name);
2833
if(countryCode) {
29-
meetup.countryName = getCountryName(countryCode);
34+
meetup.country = getCountryName(countryCode);
3035
}
3136
}
3237

src/site/community.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ layout: layouts/base.njk
8080
<span class="sr-only">Country</span>
8181
<select data-filter-bind="country" class="text-black py-1 px-2 rounded-default border border-white bg-white">
8282
<option selected value="">All Countries</option>
83-
{%- for country in community | select("countryName") | flatten | unique | sort(false, false) %}
83+
{%- for country in community | select("country") | flatten | unique | sort(false, false) %}
8484
<option value="{{ country | lower }}">{{ country }}</option>
8585
{%- endfor %}
8686
</select>
@@ -98,7 +98,7 @@ layout: layouts/base.njk
9898
{# chose a pseudorandom theme based on the city name #}
9999
{% set theme = item.name.length % 4 %}
100100
<li
101-
{%- if item.countryName %} data-filter-country="{{ item.countryName | lower }}"{% endif %}>
101+
{%- if item.country %} data-filter-country="{{ item.country | lower }}"{% endif %}>
102102
{{ meetup.card( item.name, item.link, themes[theme] ) }}
103103
</li>
104104
{%- endfor %}

0 commit comments

Comments
 (0)