@u-blox/custom-feed
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@u-blox/custom-feed", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Feed is a RSS, Atom and JSON feed generator for Node.js, making content syndication simple and intuitive!", | ||
@@ -55,2 +55,2 @@ "homepage": "https://github.com/afar-ublox/custom-feed", | ||
} | ||
} | ||
} |
import { Feed } from "./feed"; | ||
import { Author, Category, Extension, Item } from "./typings"; | ||
import { Extension } from "./typings"; | ||
@@ -46,64 +46,5 @@ /** | ||
feed.items = items.map((item: Item) => { | ||
let feedItem: any = { | ||
id: item.id, | ||
// json_feed distinguishes between html and text content | ||
// but since we only take a single type, we'll assume HTML | ||
content_html: item.content, | ||
}; | ||
if (item.link) { | ||
feedItem.url = item.link; | ||
} | ||
if (item.title) { | ||
feedItem.title = item.title; | ||
} | ||
if (item.description) { | ||
feedItem.summary = item.description; | ||
} | ||
feed.items = items; | ||
if (item.image) { | ||
feedItem.image = item.image; | ||
} | ||
if (item.date) { | ||
feedItem.date_modified = item.date.toISOString(); | ||
} | ||
if (item.published) { | ||
feedItem.date_published = item.published.toISOString(); | ||
} | ||
if (item.author) { | ||
let author: Author | Author[] = item.author; | ||
if (author instanceof Array) { | ||
// json feed only supports 1 author per post | ||
author = author[0]; | ||
} | ||
feedItem.author = {}; | ||
if (author.name) { | ||
feedItem.author.name = author.name; | ||
} | ||
if (author.link) { | ||
feedItem.author.url = author.link; | ||
} | ||
} | ||
if (Array.isArray(item.category)) { | ||
feedItem.tags = []; | ||
item.category.map((category: Category) => { | ||
if (category.name) { | ||
feedItem.tags.push(category.name); | ||
} | ||
}); | ||
} | ||
if (item.extensions) { | ||
item.extensions.map((e: Extension) => { | ||
feedItem[e.name] = e.objects; | ||
}); | ||
} | ||
return feedItem; | ||
}); | ||
return JSON.stringify(feed, null, 4); | ||
}; |
import * as convert from "xml-js"; | ||
import { generator } from "./config"; | ||
import { Feed } from "./feed"; | ||
import { Author, Category, Enclosure, Item } from "./typings"; | ||
import { Category, Enclosure, Item } from "./typings"; | ||
import { sanitize } from "./utils"; | ||
@@ -119,79 +119,3 @@ | ||
ins.items.map((entry: Item) => { | ||
let item: any = {}; | ||
if (entry.title) { | ||
item.title = { _cdata: entry.title }; | ||
} | ||
if (entry.link) { | ||
item.link = { _text: sanitize(entry.link) }; | ||
} | ||
if (entry.guid) { | ||
item.guid = { _text: entry.guid }; | ||
} else if (entry.id) { | ||
item.guid = { _text: entry.id }; | ||
} else if (entry.link) { | ||
item.guid = { _text: sanitize(entry.link) }; | ||
} | ||
if (entry.date) { | ||
item.pubDate = { _text: entry.date.toUTCString() }; | ||
} | ||
if (entry.published) { | ||
item.pubDate = { _text: entry.published.toUTCString() }; | ||
} | ||
if (entry.description) { | ||
item.description = { _cdata: entry.description }; | ||
} | ||
if (entry.content) { | ||
isContent = true; | ||
item["content:encoded"] = { _cdata: entry.content }; | ||
} | ||
/** | ||
* Item Author | ||
* https://validator.w3.org/feed/docs/rss2.html#ltauthorgtSubelementOfLtitemgt | ||
*/ | ||
if (Array.isArray(entry.author)) { | ||
item.author = []; | ||
entry.author.map((author: Author) => { | ||
if (author.email && author.name) { | ||
item.author.push({ _text: author.email + " (" + author.name + ")" }); | ||
} | ||
}); | ||
} | ||
/** | ||
* Item Category | ||
* https://validator.w3.org/feed/docs/rss2.html#ltcategorygtSubelementOfLtitemgt | ||
*/ | ||
if (Array.isArray(entry.category)) { | ||
item.category = []; | ||
entry.category.map((category: Category) => { | ||
item.category.push(formatCategory(category)); | ||
}); | ||
} | ||
/** | ||
* Item Enclosure | ||
* https://validator.w3.org/feed/docs/rss2.html#ltenclosuregtSubelementOfLtitemgt | ||
*/ | ||
if (entry.enclosure) { | ||
item.enclosure = formatEnclosure(entry.enclosure); | ||
} | ||
if (entry.image) { | ||
item.enclosure = formatEnclosure(entry.image, "image"); | ||
} | ||
if (entry.audio) { | ||
item.enclosure = formatEnclosure(entry.audio, "audio"); | ||
} | ||
if (entry.video) { | ||
item.enclosure = formatEnclosure(entry.video, "video"); | ||
} | ||
let item: any = entry; | ||
base.rss.channel.item.push(item); | ||
@@ -198,0 +122,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293201
6233
34
1