Implement announcement status and make events upcoming or planned accordingly, fill in the Luma links

This commit is contained in:
Bashy 2026-10-05 23:23:02 +03:00
parent e51d53994a
commit bda956da23
9 changed files with 49 additions and 20 deletions

View file

@ -1,5 +1,16 @@
'use strict'; 'use strict';
// Same query Hexo uses for its default `posts` local. We start from this on
// every run instead of hexo.locals.get('posts'), because we overwrite that
// local below; under `hexo server` the next regeneration would otherwise start
// from the already-filtered list and lose the hidden events for good.
function basePosts() {
const query = {};
if (!hexo.config.future) query.date = { $lte: Date.now() };
if (!hexo._showDrafts()) query.published = true;
return hexo.model('Post').find(query);
}
hexo.extend.filter.register('before_generate', function () { hexo.extend.filter.register('before_generate', function () {
const today = new Date(); const today = new Date();
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
@ -9,7 +20,8 @@ hexo.extend.filter.register('before_generate', function () {
post.tags.data.some(function (t) { return t.name === 'Events'; }); post.tags.data.some(function (t) { return t.name === 'Events'; });
} }
const allPosts = hexo.locals.get('posts').toArray(); const posts = basePosts();
const allPosts = posts.toArray();
const eventPosts = allPosts const eventPosts = allPosts
.filter(isEventPost) .filter(isEventPost)
@ -22,30 +34,38 @@ hexo.extend.filter.register('before_generate', function () {
return p.date.valueOf() >= today.getTime(); return p.date.valueOf() >= today.getTime();
}); });
hexo.locals.set('nextEvent', futureEvents[0] || false); // `event.announced: false` marks a planned date that isn't confirmed yet.
// Such events never become the homepage "Next Meetup".
function isAnnounced(p) {
return !(p.event && p.event.announced === false);
}
const nextEvent = futureEvents.find(isAnnounced) || false;
hexo.locals.set('nextEvent', nextEvent);
// Most recent past event that actually has a video (skips TBD / missing). // Most recent past event that actually has a video (skips TBD / missing).
const pastWithVideo = pastEvents.filter(function (p) { const pastWithVideo = pastEvents.filter(function (p) {
return p.event && p.event.video && p.event.video !== 'TBD'; return p.event && p.event.video && p.event.video !== 'TBD';
}); });
hexo.locals.set('lastEvent', pastWithVideo[pastWithVideo.length - 1] || false); hexo.locals.set('lastEvent', pastWithVideo[pastWithVideo.length - 1] || false);
// Far-future events (all future except the nearest one) are excluded from // Far-future events (all future except the nearest one and the next
// site.posts so they don't appear in archives or RSS. // announced one) are excluded from site.posts so they don't appear in
const hiddenIds = new Set(futureEvents.slice(1).map(function (p) { return p._id; })); // archives or RSS.
const hiddenIds = new Set(futureEvents
.filter(function (p) { return p !== futureEvents[0] && p !== nextEvent; })
.map(function (p) { return p._id; }));
// Every event (including hidden far-future ones) for the /events/ timeline. // Every event (including hidden far-future ones) for the /events/ timeline.
// `hasPage` is false for hidden events, since no page is generated for them. // `hasPage` is false for hidden events, since no page is generated for them.
hexo.locals.set('allEvents', eventPosts.map(function (p) { hexo.locals.set('allEvents', eventPosts.map(function (p) {
let state = 'upcoming'; let state = 'upcoming';
if (p.date.valueOf() < today.getTime()) state = 'past'; if (p.date.valueOf() < today.getTime()) state = 'past';
else if (p === futureEvents[0]) state = 'next'; else if (p === nextEvent) state = 'next';
else if (!isAnnounced(p)) state = 'planned';
return { post: p, state: state, hasPage: !hiddenIds.has(p._id) }; return { post: p, state: state, hasPage: !hiddenIds.has(p._id) };
})); }));
if (hiddenIds.size > 0) { hexo.locals.set('posts', posts.filter(function (p) {
const filtered = hexo.locals.get('posts').filter(function (p) { return !hiddenIds.has(p._id);
return !hiddenIds.has(p._id); }));
});
hexo.locals.set('posts', filtered);
}
}); });

View file

@ -16,7 +16,7 @@ event:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/toyaccfg"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -10,13 +10,14 @@ tags:
- "IRL Events" - "IRL Events"
- "Events" - "Events"
event: event:
announced: false
date: "11th March 2027" date: "11th March 2027"
time: "6 PM" time: "6 PM"
place: place:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/3s725ztk"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -10,13 +10,14 @@ tags:
- "IRL Events" - "IRL Events"
- "Events" - "Events"
event: event:
announced: false
date: "13th May 2027" date: "13th May 2027"
time: "6 PM" time: "6 PM"
place: place:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/ffkx30fw"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -10,13 +10,14 @@ tags:
- "IRL Events" - "IRL Events"
- "Events" - "Events"
event: event:
announced: false
date: "8th July 2027" date: "8th July 2027"
time: "6 PM" time: "6 PM"
place: place:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/ql885rt0"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -10,13 +10,14 @@ tags:
- "IRL Events" - "IRL Events"
- "Events" - "Events"
event: event:
announced: false
date: "9th September 2027" date: "9th September 2027"
time: "6 PM" time: "6 PM"
place: place:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/g1sqd6kg"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -10,13 +10,14 @@ tags:
- "IRL Events" - "IRL Events"
- "Events" - "Events"
event: event:
announced: false
date: "11th November 2027" date: "11th November 2027"
time: "6 PM" time: "6 PM"
place: place:
name: "Centrul pentru Tineret" name: "Centrul pentru Tineret"
link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912" link: "https://www.openstreetmap.org/?mlat=46.770295&mlon=23.590912#map=19/46.770295/23.590912"
osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>' osm: '<iframe width="425" height="350" src="https://www.openstreetmap.org/export/embed.html?bbox=23.58924508094788%2C46.76946689665355%2C23.59257906675339%2C46.77112397154615&amp;layer=mapnik&amp;marker=46.77029544047259%2C23.59091207385063"></iframe>'
luma: false luma: "https://luma.com/mhoxg814"
program: "TBD" program: "TBD"
video: "TBD" video: "TBD"
attendees: "TBD" attendees: "TBD"

View file

@ -14,7 +14,7 @@
var ev = p.event || {}; var ev = p.event || {};
var cancelled = ev.status === "cancelled"; var cancelled = ev.status === "cancelled";
var hasVideo = ev.video && ev.video !== "TBD"; var hasVideo = ev.video && ev.video !== "TBD";
var labels = { past: "Past", next: "Next meetup", upcoming: "Upcoming" }; var labels = { past: "Past", next: "Next meetup", upcoming: "Upcoming", planned: "Planned" };
%> %>
<li class="timeline-item <%= item.state %><%= cancelled ? ' cancelled' : '' %>"<% if (item.state === 'next') { %> id="next-event"<% } %>> <li class="timeline-item <%= item.state %><%= cancelled ? ' cancelled' : '' %>"<% if (item.state === 'next') { %> id="next-event"<% } %>>
<div class="timeline-card"> <div class="timeline-card">
@ -25,7 +25,7 @@
</h2> </h2>
<p class="timeline-meta"> <p class="timeline-meta">
<strong><%= ev.date %></strong><% if (ev.time) { %> &nbsp;·&nbsp; <strong><%= ev.time %></strong><% } %> <strong><%= ev.date %></strong><% if (ev.time) { %> &nbsp;·&nbsp; <strong><%= ev.time %></strong><% } %>
<% if (ev.place && ev.place !== "TBD") { %> <% if (item.state !== "planned" && ev.place && ev.place !== "TBD") { %>
<br><span class="timeline-loc"><%- icon('lucide:map-pin') %> <%= ev.place.name %></span> <br><span class="timeline-loc"><%- icon('lucide:map-pin') %> <%= ev.place.name %></span>
<% } %> <% } %>
</p> </p>

View file

@ -860,6 +860,10 @@ h1.event.cancelled {
} }
.timeline-item.next .timeline-card { border-color: #fcd116; } .timeline-item.next .timeline-card { border-color: #fcd116; }
/* Planned (event.announced: false): date not confirmed yet */
.timeline-item.planned::after { border-style: dashed; }
.timeline-item.planned .timeline-card { border-style: dashed; opacity: 0.6; }
.timeline-item.past .timeline-card { opacity: 0.75; } .timeline-item.past .timeline-card { opacity: 0.75; }
.timeline-kicker { .timeline-kicker {