Files
indiekit-blog/feed.njk
svemagie 89fbd222f2 feat: add Umami reader-source tracking tags
Classify visitors by referrer into segments (direct, search, fediverse,
bluesky, indieweb, web) via a custom umami.track('reader-source') event.
Add noscript pixels to RSS/JSON feeds so feed-reader activity appears
under virtual /rss/* paths in Umami.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 09:04:34 +01:00

49 lines
2.2 KiB
Plaintext

---
permalink: /feed.xml
eleventyExcludeFromCollections: true
eleventyImport:
collections:
- feed
---
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>{{ site.name }}</title>
<link>{{ site.url }}/</link>
<description>{{ site.description }}</description>
<language>{{ site.locale | default('en') }}</language>
<atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml"/>
<atom:link href="https://websubhub.com/hub" rel="hub"/>
{%- set listedFeedPosts = collections.feed | excludeUnlistedPosts %}
{%- if listedFeedPosts.length %}
<lastBuildDate>{{ listedFeedPosts | getNewestCollectionItemDate | dateToRfc822 }}</lastBuildDate>
{%- endif %}
{%- for post in listedFeedPosts %}
{%- set absolutePostUrl = site.url + post.url %}
{%- set postImage = post.data.photo %}
{%- if postImage %}
{# If photo is an array, use first element (check if first element looks like a URL) #}
{%- if postImage[0] and (postImage[0] | length) > 10 %}
{%- set postImage = postImage[0] %}
{%- endif %}
{%- endif %}
{%- if not postImage or postImage == "" %}
{%- set postImage = post.data.image or (post.content | extractFirstImage) %}
{%- endif %}
<item>
<title>{{ post.data.title | default(post.content | striptags | truncate(80)) | escape }}</title>
<link>{{ absolutePostUrl }}</link>
<guid isPermaLink="true">{{ absolutePostUrl }}</guid>
<pubDate>{{ post.date | dateToRfc822 }}</pubDate>
{%- set _rssPixel = '<img src="https://cloud.umami.is/noscript.gif?website-id=bbaa63e7-6dd2-4a4e-bbb2-68e9e75600f0&url=/rss' + post.url + '" width="1" height="1" alt="" style="display:none">' %}
<description>{{ (post.content | htmlToAbsoluteUrls(absolutePostUrl) + _rssPixel) | escape }}</description>
{%- if postImage and postImage != "" and (postImage | length) > 10 %}
{%- set imageUrl = postImage | url | absoluteUrl(site.url) %}
<enclosure url="{{ imageUrl }}" type="image/jpeg" length="0"/>
<media:content url="{{ imageUrl }}" medium="image"/>
{%- endif %}
</item>
{%- endfor %}
</channel>
</rss>