
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
ts-rss-builder
Advanced tools
A Zero-Dependency TypeScript RSS builder for Astro.
Generate RSS feeds from Astro collections with ease. Built for NN1 Spotlights RSS feed.
For learning and to keep things simple. Most RSS builders have alot of deps and stuff you don't need. My library is zero-dep, easy to understand, and made to play nicely with Astro collections.
pnpm install ts-rss-builder
import { getCollection } from 'astro:content';
import { createRSSFromAstroCollection } from 'ts-rss-builder';
import sanitizeHtml from 'sanitize-html';
const baseUrl = "https://example.com";
const blog = await getCollection('blog');
return createRSSFromAstroCollection(blog, {
site: baseUrl,
feedUrl: `${baseUrl}/blog.xml`,
mappers: {
title: (entry) => entry.data.name,
link: (entry) => `${baseUrl}/blog/${entry.id}`,
description: (entry) => generateDescription(entry), // You'd usually get this from entry.data
content: (entry) => sanitizeContent(entry.rendered?.html || entry.body || ''), // sanitizeHtml is a custom defined wrapping sanitizeHtml
pubDate: (entry) => entry.data.date,
guid: (entry) => `${baseUrl}/blog/${entry.id}`,
enclosure: (entry) => createImageEnclosure(entry, baseUrl, isDev), // // You'd usually get this from entry.data (image)
},
});
interface AstroRSSConfig<T = any> {
title: string; // Feed title
description: string; // Feed description
site: string; // Base site URL (e.g. https://example.com)
feedUrl: string; // Full URL to the RSS feed (e.g. https://example.com/feed.xml)
language?: string; // Optional language code (e.g. "en-GB")
customData?: string; // Optional raw XML string for additional RSS tags/namespaces
mappers: {
title: (entry: T) => string; // Map entry to item title
link: (entry: T) => string; // Map entry to item link
description: (entry: T) => string; // Map entry to item description (typically summary)
content: (entry: T) => string; // Map entry to item full content (for content:encoded)
pubDate: (entry: T) => string | Date; // Map entry to publication date (ISO string or Date)
category?: (entry: T) => string | string[] | undefined; // Optional categories/tags
guid?: (entry: T) => string; // Optional unique identifier for the item
enclosure?: (entry: T) => RSSEnclosure | undefined; // Optional media enclosure
};
}
interface RSSEnclosure {
url: string;
length?: number | string;
type?: string; // MIME type, e.g. "image/jpeg"
}
This builder is designed with XML correctness and security in mind. Here are some techniques it uses:
<content:encoded>
is wrapped in CDATA sections to allow HTML without heavy escaping.FAQs
RSS builder in Typescript, tailored to Astro. For NN1.dev
The npm package ts-rss-builder receives a total of 5 weekly downloads. As such, ts-rss-builder popularity was classified as not popular.
We found that ts-rss-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.