The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(feed): add external tag to linkposts in RSS feeds (#1059)

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.

authored by

Xe Iaso and committed by
GitHub
fe0c6c40 2a713652

+15
+15
lume/plugins/feed.ts
··· 119 119 updated?: Date; 120 120 content: string; 121 121 lang: string; 122 + categories?: string[]; 122 123 } 123 124 124 125 const defaultGenerator = `Lume ${getCurrentVersion()}`; ··· 156 157 const fixedContent = fixUrls(new URL(pageUrl), content || ""); 157 158 158 159 const link = getDataValue(data, "=redirect_to") ?? site.url(data.url, true); 160 + const isLinkpost = getDataValue(data, "=redirect_to") !== undefined; 161 + 162 + // Get existing tags from frontmatter 163 + const existingTags = getDataValue(data, "=tags") as string[] || []; 164 + 165 + // Add "external" tag for linkposts 166 + const categories = isLinkpost 167 + ? [...existingTags, "external"] 168 + : existingTags; 159 169 160 170 return { 161 171 title: getDataValue(data, items.title), ··· 165 175 updated: getDataValue(data, items.updated), 166 176 content: fixedContent, 167 177 lang: getDataValue(data, items.lang), 178 + categories, 168 179 }; 169 180 }), 170 181 }; ··· 242 253 "content:encoded": item.content, 243 254 pubDate: item.published.toUTCString(), 244 255 "atom:updated": item.updated?.toISOString(), 256 + category: item.categories?.map((category) => ({ 257 + "#text": category, 258 + })), 245 259 }) 246 260 ), 247 261 }), ··· 266 280 content_html: item.content, 267 281 date_published: item.published.toISOString(), 268 282 date_modified: item.updated?.toISOString(), 283 + tags: item.categories, 269 284 }) 270 285 ), 271 286 });