Skip to content

Commit 5766acd

Browse files
committed
validate that articlebody is not empty
1 parent 2c57cd1 commit 5766acd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

plugins/links/article/article.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import * as cheerio from 'cheerio';
2+
13
export default {
24

3-
provides: 'articlebody',
5+
provides: 'articlebody', // if not yet provided from LD articlebody
46

57
getData: function(__readabilityEnabled, readability, meta, utils) {
6-
return {
7-
articlebody: utils.encodeText(meta.charset, readability.getHTML())
8+
9+
const articleHtml = utils.encodeText(meta.charset, readability.getHTML());
10+
const $p = cheerio.load(articleHtml)('p');
11+
12+
if ($p.text()) {
13+
return {
14+
articlebody: articleHtml
15+
}
816
}
917
},
1018

0 commit comments

Comments
 (0)