@bliztek/feed-generator
Version:
A simple and lightweight Node.js library for generating RSS 2.0, Atom, and JSON Feed formats.
53 lines (52 loc) • 1.75 kB
TypeScript
import { Feed, FeedItem, FeedAuthor, FeedCategory, FeedImage, FeedFormat, FeedOptions, FeedOutput, FeedExtensions, PodcastFeed } from "./types.js";
/**
* Fluent builder for constructing feeds incrementally.
*
* @example
* ```ts
* const rss = new FeedBuilder()
* .title("My Blog")
* .link("https://example.com")
* .description("Latest posts.")
* .addItem({ id: "1", title: "Hello", content: "<p>World</p>" })
* .generate("rss");
* ```
*/
export declare class FeedBuilder {
private feed;
private opts;
title(title: string): this;
link(link: string): this;
description(description: string): this;
id(id: string): this;
language(language: string): this;
copyright(copyright: string): this;
updated(updated: string | Date): this;
generator(generator: string): this;
image(image: FeedImage): this;
favicon(favicon: string): this;
author(author: FeedAuthor): this;
category(category: FeedCategory): this;
nextUrl(nextUrl: string): this;
podcast(podcast: PodcastFeed): this;
ttl(ttl: number): this;
skipHours(hours: number[]): this;
skipDays(days: string[]): this;
feedLinks(links: {
rss?: string;
atom?: string;
json?: string;
hub?: string;
}): this;
hub(url: string): this;
extensions(ext: FeedExtensions): this;
stylesheet(url: string): this;
addItem(item: FeedItem): this;
addItems(items: FeedItem[]): this;
/** Build the feed data object without rendering. */
build(): Feed;
/** Render the feed in a single format. */
generate(format: FeedFormat, options?: FeedOptions): string;
/** Render all three formats at once. */
generateAll(options?: FeedOptions): FeedOutput;
}