Skip to content
This repository was archived by the owner on May 2, 2021. It is now read-only.

Commit c4f3c70

Browse files
committed
add a fetured flag for events to be displayed on the HP hero
1 parent 45ec86a commit c4f3c70

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

.eleventy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module.exports = function(eleventyConfig) {
3333
return posts.slice(0, num);
3434
});
3535

36+
eleventyConfig.addNunjucksFilter('featuredEvent', (posts) => {
37+
// return a featured event or the first one
38+
return posts.find(({ data }) => data.featured) || posts[0];
39+
});
40+
3641
// redirect collection
3742
eleventyConfig.addCollection('redirects', function(collection) {
3843
const redirs = collection.getAll().filter(({ data }) => data.redirect_from);

src/index.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ layout: default
33
isHome: true
44
---
55

6-
{% set post = collections.eventi | published | last %}
6+
{% set post = collections.eventi | published | reverse | featuredEvent %}
77
<!-- Slider Start -->
88
<section id="slider" style="background-image: url({{ post.data.cover }})">
99
<div class="container">
1010
<div class="row">
1111
<div class="col-xs-12">
1212
<div class="block">
13-
<p class="sr-only">Prossimo evento</p>
13+
<p class="sr-only">Evento in primo piano</p>
1414
<h1 class="animated fadeInUp">{{post.data.title | upper }}</h1>
1515
<div class="animated fadeInUp buttons">
1616
<p>

static/admin/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ collections:
3535
default: '/eventi/{{ page.date | dateslug }}/{{ page.fileSlug | slug }}/index.html'
3636
- widget: boolean
3737
name: published
38-
label: Pubblicato
38+
label: Visibile
39+
default: false
40+
- widget: boolean
41+
name: featured
42+
label: In Primo Piano (Hero)
3943
default: false
4044
- widget: object
4145
name: event

0 commit comments

Comments
 (0)