Parse some fields off each item

This commit is contained in:
Hamcha 2019-07-16 16:47:51 +02:00
parent 8257347a09
commit 28788c8fc0
2 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,10 @@ import { Item } from "rss-parser";
export function toEvent(item: Item): FeedEventData { export function toEvent(item: Item): FeedEventData {
return { return {
guid: item.guid || item.link || item.title || Math.random().toString(32) guid: item.guid || item.link || item.title || Math.random().toString(32),
title: item.title || "Unnamed event",
link: item.link,
creator: item.creator || "Unknown",
published: item.pubDate ? new Date(item.pubDate) : undefined
}; };
} }

View File

@ -21,6 +21,10 @@ export interface FeedEvent {
export interface FeedEventData { export interface FeedEventData {
guid: string; guid: string;
title: string;
link?: string;
creator: string;
published?: Date;
} }
export interface FetchStatus { export interface FetchStatus {