Skip to content

Commit

Permalink
Merge pull request #58 from ndaidong/dev
Browse files Browse the repository at this point in the history
v6.1.2
  • Loading branch information
ndaidong authored Sep 25, 2022
2 parents 084a26d + 87e50eb commit 5a68f9b
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 230 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ Without any options, the result should have the following structure:
Object with all or several of the following properties:

- `normalization`: Boolean, normalize feed data or keep original. Default `true`.
- `includeEntryContent`: Boolean, include full content of feed entry if present. Default `false`.
- `includeOptionalElements`: Boolean, include optional elements. Default `false`.
- `useISODateFormat`: Boolean, convert datetime to ISO format. Default `true`.
- `descriptionMaxLen`: Number, to truncate description. Default `210` (characters).

Note that when `normalization` is set to `false`, other options will take no effect to the last output.
- `xmlParserOptions`: Object, used by xml parser, view [fast-xml-parser's docs](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md)
- `getExtraFeedFields`: Function, to get more fields from feed data
- `getExtraEntryFields`: Function, to get more fields from feed entry data

For example:

Expand All @@ -134,7 +133,28 @@ read('https://news.google.com/atom', {

read('https://news.google.com/rss', {
useISODateFormat: false,
includeOptionalElements: true
getExtraFeedFields: (feedData) => {
return {
subtitle: feed.subtitle || ''
}
},
getExtraEntryFields: (feedEntry) => {
const {
enclosure,
category
} = feedEntry
return {
enclosure: {
url: enclosure['@_url'],
type: enclosure['@_type'],
length: enclosure['@_length']
},
category: isString(category) ? category : {
text: category['@_text'],
domain: category['@_domain']
}
}
}
})
```

Expand Down
96 changes: 54 additions & 42 deletions dist/cjs/feed-reader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions dist/cjs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ export interface ReaderOptions {
* default: 210
*/
descriptionMaxLen?: number;
/**
* fast-xml-parser options
* https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md
*/
xmlParserOptions?: any;
/**
* merge extra feed fields in result
*/
extraFeedFields?: (feedData: object) => object;
/**
* merge extra entry fields in result
*/
extraEntryFields?: (entryData: object) => object;
}

export interface FetchOptions {
Expand Down
2 changes: 1 addition & 1 deletion dist/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "feed-reader",
"version": "6.1.1",
"version": "6.1.2",
"main": "./feed-reader.js"
}
Loading

0 comments on commit 5a68f9b

Please sign in to comment.