diff --git a/eleventy.config.js b/eleventy.config.js
index dd9b899..b9bcadf 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -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 "";
diff --git a/listening.njk b/listening.njk
index 7c1daa4..3cb3f3a 100644
--- a/listening.njk
+++ b/listening.njk
@@ -265,122 +265,69 @@ withSidebar: true
Recent Listens
+ {% set combinedListens = funkwhaleActivity.listenings | mergeListens(lastfmActivity.scrobbles) | head(20) %}
+
- {# Funkwhale Listenings #}
- {% if funkwhaleActivity.listenings.length %}
-
- {% for listening in funkwhaleActivity.listenings | head(10) %}
-
- {% if listening.coverUrl %}
-

- {% else %}
-
- {% endif %}
-
-
-
- {% if listening.trackUrl %}
- {{ listening.track }}
- {% else %}
- {{ listening.track }}
- {% endif %}
- {% if listening.favorite %}
- ♥
- {% endif %}
-
-
{{ listening.artist }}
-
-
-
- Funkwhale
- {{ listening.relativeTime }}
-
-
-
+ {% if combinedListens.length %}
+ {% for item in combinedListens %}
+
+ {% if item.coverUrl %}
+

+ {% else %}
+
- {% endfor %}
-
- {% endif %}
+ {% endif %}
- {# Last.fm Scrobbles #}
- {% if lastfmActivity.scrobbles.length %}
-
- {% for scrobble in lastfmActivity.scrobbles | head(10) %}
-
- {% if scrobble.coverUrl %}
-

- {% else %}
-
- {% endif %}
-
-
-
- {% if scrobble.trackUrl %}
- {{ scrobble.track }}
- {% else %}
- {{ scrobble.track }}
- {% endif %}
- {% if scrobble.loved %}
- ♥
- {% endif %}
-
-
{{ scrobble.artist }}
-
-
-
- Last.fm
- {{ scrobble.relativeTime }}
-
-
-
+
+
+ {% if item.trackUrl %}
+ {{ item.track }}
+ {% else %}
+ {{ item.track }}
+ {% endif %}
+ {% if item.favorite or item.loved %}
+ ♥
+ {% endif %}
+
+
{{ item.artist }}
- {% endfor %}
-
- {% endif %}
- {% if not funkwhaleActivity.listenings.length and not lastfmActivity.scrobbles.length %}
+
+ {% if item._source == 'funkwhale' %}
+ Funkwhale
+ {% else %}
+ Last.fm
+ {% endif %}
+ {{ item.relativeTime }}
+
+
+
+
+ {% endfor %}
+ {% else %}
No recent listening history available.
{% endif %}