File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -225,9 +225,40 @@ These plugins will not be shipped with **metascraper** by default and need to b
225
225
226
226
# # Write your own plugin
227
227
228
- Write your own plugin is the way to easily extend **metascraper** functionality.
228
+ A plugin is the simplest way for extending **metascraper** functionality.
229
229
230
- *SOON*
230
+ The following schema represents the API compromise that a plugin need to follow :
231
+
232
+ ` ` ` js
233
+ 'use strict'
234
+
235
+ // ` opts` can be loaded using `.metascraperrc`
236
+ // confguration file
237
+ module.exports = opts => {
238
+ // define as `rule` as you want.
239
+ // They receive as parameter :
240
+ // - htmlDom : the cheerio HTML instance.
241
+ // - url : The input URL used for extact the content.
242
+ // - meta : The current state of the information detected.
243
+ const rule = ({ htmlDom, meta, url : baseUrl }) => {
244
+ // the logic for determinate if apply or not the rule.
245
+ // just return the data that you want to be
246
+ // assigned to the final output
247
+ return !meta.name && 'hello world'
248
+ }
249
+
250
+ // Rules need to follow an `array` interface.
251
+ const rules = [rule]
252
+
253
+ // Need to assign a property name
254
+ rules.propName = 'logo'
255
+
256
+ // export the rules!
257
+ return rules
258
+ }
259
+ ```
260
+
261
+ We recommend check [ core plugins packages] ( /packages ) as examples to understand better how to connect your code with ** metascraper** plugins.
231
262
232
263
## API
233
264
You can’t perform that action at this time.
0 commit comments