From 3bfe17e53d9a96f307a068b497ed37a5870d86e4 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 1 Nov 2025 08:50:24 -0400 Subject: [PATCH] feat(feed): add external tag to linkposts in RSS feeds Closes SITE-9 Add support for automatically tagging linkposts (posts with redirect_to field) with an "external" tag in both RSS and JSON feeds. This allows readers to perform client-side filtering to identify external content. --- lume/plugins/feed.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lume/plugins/feed.ts b/lume/plugins/feed.ts index 47b4db59e..328c08b4c 100644 --- a/lume/plugins/feed.ts +++ b/lume/plugins/feed.ts @@ -119,6 +119,7 @@ export interface FeedItem { updated?: Date; content: string; lang: string; + categories?: string[]; } const defaultGenerator = `Lume ${getCurrentVersion()}`; @@ -156,6 +157,15 @@ export default function (userOptions?: Options) { const fixedContent = fixUrls(new URL(pageUrl), content || ""); const link = getDataValue(data, "=redirect_to") ?? site.url(data.url, true); + const isLinkpost = getDataValue(data, "=redirect_to") !== undefined; + + // Get existing tags from frontmatter + const existingTags = getDataValue(data, "=tags") as string[] || []; + + // Add "external" tag for linkposts + const categories = isLinkpost + ? [...existingTags, "external"] + : existingTags; return { title: getDataValue(data, items.title), @@ -165,6 +175,7 @@ export default function (userOptions?: Options) { updated: getDataValue(data, items.updated), content: fixedContent, lang: getDataValue(data, items.lang), + categories, }; }), }; @@ -242,6 +253,9 @@ function generateRss(data: FeedData, file: string): string { "content:encoded": item.content, pubDate: item.published.toUTCString(), "atom:updated": item.updated?.toISOString(), + category: item.categories?.map((category) => ({ + "#text": category, + })), }) ), }), @@ -266,6 +280,7 @@ function generateJson(data: FeedData, file: string): string { content_html: item.content, date_published: item.published.toISOString(), date_modified: item.updated?.toISOString(), + tags: item.categories, }) ), });