-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdev-community-rss-parser.token.ts
More file actions
41 lines (35 loc) · 1.06 KB
/
dev-community-rss-parser.token.ts
File metadata and controls
41 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { InjectionToken } from '@angular/core';
import * as RssParser from 'rss-parser';
export interface DevCommunityRssFeedCustomFields {
readonly language: string;
}
export interface DevCommunityRssItemCustomFields {
readonly author: string;
readonly contentSnippet: string;
readonly description: string;
}
export type DevCommunityRssParser = RssParser<
DevCommunityRssFeedCustomFields,
DevCommunityRssItemCustomFields
>;
export type DevCommunityRssItem = DevCommunityRssItemCustomFields &
RssParser.Item;
export type DevCommunityRssItems = readonly DevCommunityRssItem[];
export function devCommunityRssParserFactory(): DevCommunityRssParser {
return new RssParser<
DevCommunityRssFeedCustomFields,
DevCommunityRssItemCustomFields
>({
customFields: {
feed: ['language'],
item: ['author', 'contentSnippet', 'description'],
},
});
}
export const devCommunityRssParserToken = new InjectionToken<DevCommunityRssParser>(
'DEV_Community_RSS_parser',
{
factory: devCommunityRssParserFactory,
providedIn: 'root',
}
);