Skip to content

Commit

Permalink
chore(readability): add readabilityOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 16, 2025
1 parent 67b5fc0 commit 803c91f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions packages/metascraper-readability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ Default: [source code](https://github.com/microlinkhq/metascraper/blob/master/pa

The function to be called to serialized html into a DOM document.

##### readabilityOpts

Type: `object`

Any option provided here will passed to [Readability#options](https://github.com/mozilla/readability#new-readabilitydocument-options).

```json
{
"responseType": "json"
}
```

## License

**metascraper-readability** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br>
Expand Down
7 changes: 5 additions & 2 deletions packages/metascraper-readability/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ const defaultGetDocument = ({ url, html }) => {
return document
}

module.exports = ({ getDocument = defaultGetDocument } = {}) => {
module.exports = ({
getDocument = defaultGetDocument,
readabilityOpts
} = {}) => {
const readability = memoizeOne((url, html, getDocument) => {
const document = getDocument({ url, html })
const reader = new Readability(document)
const reader = new Readability(document, readabilityOpts)
return parseReader(reader)
}, memoizeOne.EqualityFirstArgument)

Expand Down

0 comments on commit 803c91f

Please sign in to comment.