feat(listening): merge Funkwhale and Last.fm into single sorted timeline

Adds a `mergeListens` Eleventy filter that combines both sources into one
array sorted newest-first by timestamp (listenedAt / scrobbledAt). The
Recent Listens section now renders a unified chronological feed with
per-source badges and Alpine filter tabs still working.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-03-21 16:38:56 +01:00
parent 9d32075b9e
commit 20e4403b00
2 changed files with 73 additions and 111 deletions

View File

@@ -670,6 +670,21 @@ export default function (eleventyConfig) {
return array.slice(0, n);
});
// Merge Funkwhale listenings and Last.fm scrobbles into a single sorted timeline
eleventyConfig.addFilter("mergeListens", (listenings, scrobbles) => {
const fw = (listenings || []).map((l) => ({
...l,
_source: "funkwhale",
_ts: new Date(l.listenedAt || l.creation_date || l.listened_at || 0).getTime(),
}));
const lfm = (scrobbles || []).map((s) => ({
...s,
_source: "lastfm",
_ts: new Date(s.scrobbledAt || 0).getTime(),
}));
return [...fw, ...lfm].sort((a, b) => b._ts - a._ts);
});
// Slugify filter
eleventyConfig.addFilter("slugify", (str) => {
if (!str) return "";