feat(feed): Support custom feedUrl for feeds and use it as the self-link in RSS/Atom/JSON; update docs

This commit is contained in:
2025-11-01 03:35:45 +00:00
parent 289483ba0a
commit 4ed892ddc2
5 changed files with 45 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
## Features ✨
- 🎯 **Full TypeScript Support** - Complete type definitions for all feed formats
- 🌐 **Cross-Platform** - Works in Node.js, Bun, Deno, and browsers
- 📡 **Multiple Feed Formats** - RSS 2.0, Atom 1.0, JSON Feed 1.0, and Podcast RSS
- 🎙️ **Modern Podcast Support** - iTunes tags, Podcast 2.0 namespace (guid, medium, locked, persons, transcripts, funding)
- 🔒 **Built-in Validation** - Comprehensive validation for URLs, emails, domains, and timestamps
@@ -57,6 +58,30 @@ const atom = feed.exportAtomFeed();
const json = feed.exportJsonFeed();
```
### Custom Feed URL
You can specify a custom URL for your feed's self-reference instead of the default `https://${domain}/feed.xml`:
```typescript
const feed = smartfeed.createFeed({
domain: 'example.com',
title: 'My Blog',
description: 'Latest posts',
category: 'Technology',
company: 'Example Inc',
companyEmail: 'hello@example.com',
companyDomain: 'https://example.com',
feedUrl: 'https://cdn.example.com/feeds/main.xml' // Custom feed URL
});
// The feedUrl will be used in:
// - RSS: <atom:link href="..." rel="self">
// - Atom: <link href="..." rel="self">
// - JSON Feed: "feed_url" field
```
This is particularly useful when your feed is hosted on a CDN or different domain than your main site.
### Creating a Podcast Feed
```typescript
@@ -183,6 +208,7 @@ Creates a standard feed (RSS/Atom/JSON).
- `company` (string) - Company/organization name
- `companyEmail` (string) - Contact email
- `companyDomain` (string) - Company website URL (absolute)
- `feedUrl` (string, optional) - Custom URL for the feed's self-reference (defaults to `https://${domain}/feed.xml`)
#### `createPodcastFeed(options: IPodcastFeedOptions): PodcastFeed`