forked from roxiness/poindexter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefaults.js
37 lines (35 loc) · 1.07 KB
/
defaults.js
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
module.exports = {
flexsearch: {
doc: {
id: 'path',
field: 'text'
},
encode: 'advanced'
},
docs: 'dist',
output: 'poindexter.bundle.json',
contentSelectors: [
'main main', 'main',
'.container .container', '.container'
],
ignoreSelectors: ['nav'],
title: $ => $('title').text().trim(),
description: $ => $('meta[name=description]').attr('content'),
keywords: $ => $('meta[name=keywords]').attr('content').split(','),
scrape: async ($, path, cfg) => {
const title = cfg.title($)
const description = cfg.description($)
const keywords = cfg.keywords($)
// strip unwanted content
for (const is of cfg.ignoreSelectors) {
$(is).remove()
}
// we use the text from the first matching content selector
for (const qs of cfg.contentSelectors) {
const text = $(qs).text().trim()
if (text){
return { text, title, description, keywords }
}
}
}
}