diff --git a/api/resolvers/item.js b/api/resolvers/item.js index e8fc67f4..e9b59d4e 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -324,6 +324,12 @@ export default { } } } + }, + highlight: { + fields: { + title: { number_of_fragments: 0, pre_tags: ['***'], post_tags: ['***'] }, + text: { number_of_fragments: 0, pre_tags: ['***'], post_tags: ['***'] } + } } } }) @@ -335,7 +341,18 @@ export default { } } - const items = sitems.body.hits.hits.map(e => e._source) + // return highlights + const items = sitems.body.hits.hits.map(e => { + const item = e._source + if (e.highlight?.title) { + item.title = e.highlight.title[0] + } + if (e.highlight?.text) { + item.text = e.highlight.text[0] + } + return item + }) + return { cursor: items.length === LIMIT ? nextCursorEncoded(decodedCursor) : null, items diff --git a/spawn/capture.js b/spawn/capture.js index 71631605..fe59dd01 100755 --- a/spawn/capture.js +++ b/spawn/capture.js @@ -4,7 +4,7 @@ const Pageres = require('pageres') async function captureUrl () { try { - const streams = await new Pageres({ crop: true, scale: 2, timeout: 10, launchOptions: { args: ['--single-process'] } }) + const streams = await new Pageres({ crop: true, delay: 1, scale: 2, timeout: 10, launchOptions: { args: ['--single-process'] } }) .src(process.argv[2], ['600x315']) .run() process.stdout.write(streams[0], () => process.exit(0))