Adding a next event widget
This year I’d like to meet more people irl. I’ve not done a particularly good job of building an irl network over the past few years, and I’d like to change that. To help with that, and just because it was a bit of fun to put together, I’ve added a 'Next event' widget to my dashboard that shows the next irl event I’m attending
I’ve got an events.json file where I can add details like event-name, location and date
[
{
"name": "bristol coffee festival",
"date": "2026-09-12",
"city": "bristol",
"country": "england"
}
]
And then a nextEvent.js script that finds the next upcoming event (I did have to chatGPT this because it’s way out of my league atm).
module.exports = () => {
const events = require("./events.json");
const now = new Date();
now.setHours(0,0,0,0);
return events
.map(e => ({ ...e, dateObj: new Date(e.date) }))
.filter(e => e.dateObj >= now)
.sort((a, b) => a.dateObj - b.dateObj)[0] || null;
}
And then with a little bit of nunjucks it magically appears on the dashboard (yay!)
