Skip to content

Commit 03d29e0

Browse files
committed
Update docs
1 parent 563c583 commit 03d29e0

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ These plugins will not be shipped with **metascraper** by default and need to b
234234
| Package | Version | Dependencies |
235235
|--------|-------|------------|
236236
| [`metascraper-clearbit-logo`](/packages/metascraper-clearbit-logo) | [![npm](https://img.shields.io/npm/v/metascraper-clearbit-logo.svg?style=flat-square)](https://www.npmjs.com/package/metascraper-clearbit-logo) | [![Dependency Status](https://david-dm.org/microlinkhq/metascraper.svg?path=packages/metascraper-clearbit-logo&?style=flat-square)](https://david-dm.org/microlinkhq/metascraper?path=packages/metascraper-clearbit-logo) |
237+
| [`metascraper-soundcloud`](/packages/metascraper-soundcloud) | [![npm](https://img.shields.io/npm/v/metascraper-soundcloud.svg?style=flat-square)](https://www.npmjs.com/package/metascraper-soundcloud) | [![Dependency Status](https://david-dm.org/microlinkhq/metascraper.svg?path=packages/metascraper-soundcloud&?style=flat-square)](https://david-dm.org/microlinkhq/metascraper?path=packages/metascraper-soundcloud) |
237238

238239
### Write your own plugin
239240

@@ -244,29 +245,21 @@ The following schema represents the API compromise that a plugin need to follow:
244245
```js
245246
'use strict'
246247
247-
// `opts` can be loaded using `.metascraperrc`
248-
// confguration file
248+
// `opts` can be loaded using `.metascraperrc` config file
249249
module.exports = opts => {
250-
// define as `rule` as you want.
251-
// They receive as parameter:
252-
// - htmlDom: the cheerio HTML instance.
253-
// - url: The input URL used for extact the content.
254-
// - meta: The current state of the information detected.
255-
const rule = ({ htmlDom, meta, url: baseUrl }) => {
256-
// the logic for determinate if apply or not the rule.
257-
// just return the data that you want to be
258-
// assigned to the final output
259-
return !meta.name && 'hello world'
260-
}
261-
262-
// Rules need to follow an `array` interface.
263-
const rules = [rule]
264-
265-
// Need to assign a property name
266-
rules.propName = 'logo'
267-
268-
// export the rules!
269-
return rules
250+
// You can define as props as you want.
251+
// props are organized based on an object key.
252+
return ({
253+
logo: [
254+
// You can setup more than one rules per prop (priority is important!).
255+
// They receive as parameter:
256+
// - `htmlDom`: the cheerio HTML instance.
257+
// - `url`: The input URL used for extact the content.
258+
// - `meta`: The current state of the information detected.
259+
({ htmlDom: $, meta, url: baseUrl }) => wrap($ => $('meta[property="og:logo"]').attr('content')),
260+
({ htmlDom: $, meta, url: baseUrl }) => $('meta[itemprop="logo"]').attr('content')),
261+
]
262+
})
270263
}
271264
```
272265

0 commit comments

Comments
 (0)