@gaphub/feed
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -1,5 +0,1 @@ | ||
interface CustomField { | ||
[key: string]: CustomFieldValue; | ||
} | ||
type CustomFieldValue = string | number | boolean | undefined; | ||
interface Text { | ||
@@ -73,2 +69,57 @@ type?: "text" | "html"; | ||
} | ||
interface OpmlOptions { | ||
version: string; | ||
head: OpmlHeadOptions; | ||
body: OpmlBodyOptions; | ||
} | ||
interface OpmlHeadOptions { | ||
title?: string; | ||
description?: string; | ||
dateCreated?: Date; | ||
dateModified?: Date; | ||
ownerName?: string; | ||
ownerEmail?: string; | ||
ownerId?: string; | ||
docs?: string; | ||
expansionState?: number[]; | ||
vertScrollState?: number; | ||
windowTop?: number; | ||
windowLeft?: number; | ||
windowBottom?: number; | ||
windowRight?: number; | ||
[key: string]: any; | ||
} | ||
interface OpmlBodyOptions { | ||
outlines: OpmlOutlineOptions[]; | ||
} | ||
interface BaseOpmlOutlineOptions { | ||
text: string; | ||
isComment?: boolean; | ||
isBreakpoint?: boolean; | ||
category?: string; | ||
created?: Date; | ||
outlines?: OpmlOutlineOptions[]; | ||
} | ||
interface RSSOpmlOutlineOptions extends BaseOpmlOutlineOptions { | ||
type: "rss"; | ||
xmlUrl: string; | ||
title?: string; | ||
description?: string; | ||
htmlUrl?: string; | ||
language?: string; | ||
version?: string; | ||
} | ||
interface LinkOpmlOutlineOptions extends BaseOpmlOutlineOptions { | ||
type: "link"; | ||
url: string; | ||
} | ||
interface IncludeOpmlOutlineOptions extends BaseOpmlOutlineOptions { | ||
type: "include"; | ||
url: string; | ||
} | ||
interface OtherOpmlOutlineOptions extends BaseOpmlOutlineOptions { | ||
type?: Exclude<string, "rss" | "link" | "include">; | ||
[key: string]: any; | ||
} | ||
type OpmlOutlineOptions = RSSOpmlOutlineOptions | LinkOpmlOutlineOptions | IncludeOpmlOutlineOptions | OtherOpmlOutlineOptions; | ||
@@ -112,2 +163,16 @@ declare class FeedItem { | ||
declare class Opml { | ||
private _options; | ||
constructor(options?: OpmlOptions); | ||
get version(): string; | ||
set version(version: string); | ||
get head(): OpmlHeadOptions; | ||
set head(head: OpmlHeadOptions); | ||
setHead<K extends keyof OpmlHeadOptions>(name: K, value: OpmlHeadOptions[K]): void; | ||
get outlines(): OpmlOutlineOptions[]; | ||
set outlines(outlines: OpmlOutlineOptions[]); | ||
addOutline(outline: OpmlOutlineOptions): void; | ||
toString(): string; | ||
} | ||
declare enum ContentType { | ||
@@ -121,7 +186,9 @@ XML = 0, | ||
parse(feedURLOrContent: string, options?: FeedParseOptions): Promise<Feed | null>; | ||
parseString(content: string): Promise<Feed | null>; | ||
private getContent; | ||
parseURL(url: string | URL, options?: FeedParseOptions): Promise<Feed | null>; | ||
parseString(content: string): Feed | null; | ||
parseOPMLFromURL(url: string | URL, options?: FeedParseOptions): Promise<Opml | null>; | ||
parseOPMLString(content: string): Opml | null; | ||
private getContentFromURL; | ||
} | ||
export { type Author, type Category, ContentType, type CustomField, type CustomFieldValue, type Enclosure, type Extension, Feed, FeedItem, type FeedOptions, type FeedParseOptions, FeedParser, type ItemOptions, type Text }; | ||
export { type Author, type BaseOpmlOutlineOptions, type Category, ContentType, type Enclosure, type Extension, Feed, FeedItem, type FeedOptions, type FeedParseOptions, FeedParser, type IncludeOpmlOutlineOptions, type ItemOptions, type LinkOpmlOutlineOptions, Opml, type OpmlBodyOptions, type OpmlHeadOptions, type OpmlOptions, type OpmlOutlineOptions, type OtherOpmlOutlineOptions, type RSSOpmlOutlineOptions, type Text }; |
{ | ||
"name": "@gaphub/feed", | ||
"version": "5.0.0", | ||
"description": "Feed is a RSS, Atom and JSON feed generator/parser for Node.js, making content syndication simple and intuitive!", | ||
"version": "5.1.0", | ||
"description": "@gaphub/feed is a RSS, Atom, JSON feed and OPML generator/parser for Node.js, making content syndication simple and intuitive!", | ||
"homepage": "https://github.com/gap-hub/feed", | ||
@@ -33,2 +33,3 @@ "author": "Jon Zhang <jonzhang520s@gmail.com>", | ||
"feed", | ||
"opml", | ||
"syndication", | ||
@@ -44,3 +45,2 @@ "xml", | ||
"axios": "^1.7.7", | ||
"ky": "^1.7.2", | ||
"xml-js": "^1.6.11" | ||
@@ -47,0 +47,0 @@ }, |
<p align="center"> | ||
<a href="https://github.com/facebook/jest"><img src="https://img.shields.io/badge/tested_with-jest-99424f.svg" alt="Tested with Jest"></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a> | ||
</p> | ||
<p align="center"><code>@gaphub/feed</code> - <strong>RSS 2.0, JSON Feed 1.0, and Atom 1.0</strong> generator/parser for <strong>Node.js</strong><br> | ||
<p align="center"><code>@gaphub/feed</code> - <strong>RSS 2.0, JSON Feed 1.0, Atom 1.0 and OPML 2.0</strong> generator/parser for <strong>Node.js</strong><br> | ||
Making content syndication simple and intuitive!</p> | ||
@@ -22,5 +22,4 @@ | ||
- Support for JSON Feed 1.1 | ||
- Support for OPML 2.0 | ||
## Fixes | ||
# 🔨 Getting Started | ||
@@ -131,5 +130,4 @@ | ||
const parser = new FeedParser(); | ||
// const feed = parser.parse("<feed>...</feed>"); | ||
// const feed = parser.parseString("<feed>...</feed>"); | ||
const feed = parser.parse("https://example.com/feed.rss"); | ||
const feed = parser.parseURL("https://example.com/feed.rss"); | ||
@@ -139,2 +137,36 @@ console.log(feed); | ||
### Generate and Parse OPML | ||
```js | ||
import { FeedParser, OPML } from "@gaphub/feed"; | ||
// Generate OPML | ||
const opml = new Opml(); | ||
opml.setHead("title", "my test opml"); | ||
opml.setHead("dateCreated", new Date("Thu, 13 Oct 2005 15:34:07 GMT")); | ||
opml.head.dateModified = new Date("Thu, 13 Oct 2005 15:34:07 GMT"); | ||
opml.head.ownerName = "Jon"; | ||
opml.addOutline({ | ||
text: "United States", | ||
outlines: [ | ||
{ | ||
text: "Far West", | ||
outlines: [ | ||
{ text: "Alaska" }, | ||
{ text: "California" }, | ||
{ text: "Hawaii" }, | ||
], | ||
}, | ||
], | ||
}); | ||
const xml = opml.toString(); | ||
console.log(xml); | ||
// Parse OPML | ||
const parser = new FeedParser(); | ||
// const parsedOPML = parser.parseOPMLFromURL("https://..."); | ||
const parsedOPML = parser.parseOPMLString(xml); | ||
console.log(parsedOPML); | ||
``` | ||
## More Information | ||
@@ -141,0 +173,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99221
2
2991
182