0.3.1 • Published 5 years ago

@webalytics/rss v0.3.1

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
5 years ago

@webalytics/rss

TypeScript Build Status styled with prettier License: LGPL v3

Given some RSS or Atom feed xml, extract common metadata fields and items. Part of the Webalytics Toolbox.

Installation

npm install --save @webalytics/rss

Extracted Properties (if possible)

interface Feed {
  title: string
  description: string
  url: string
  items: Item[]
}

interface Item {
  title: string
  description: string
  url: string
  image: string
  pubDate: string
  keywords: string[]
}

Usage (convenience)

This package works out-of-the-box with any Rss/Atom feed without further configuration:

import rss from '@webalytics/rss'

const xml = '<rss><title>abc</title></rss>'
const data = rss(html) // { title: 'abc' }

Usage (convenience, with url aid)

When given an additional hint with the base url of the feed document, relative urls can be resolved correctly:

import rss from '@webalytics/rss'

const url = 'http://example.com'
const xml = '<rss><image><url>/img</url></image></rss>'
const data = rss(xml, url) // { image: 'http://example.com/img' }

License

LGPL v3. You can use this code any way you want without restrictions, but I want bugfixes and improvements to flow back to this repository to benefit everyone.