fix: lazy-load images cannot be displayed in 三界异次元 (#3535)

This commit is contained in:
Luyu Huang 2019-12-08 02:37:10 +08:00 committed by DIYgod
parent dda1b6b5e7
commit 7b96a4579c
2 changed files with 11 additions and 2 deletions

View File

@ -233,7 +233,7 @@ pageClass: routes
### 三界异次元
<Route author="luyuhuang" example="/3ycy/home" path="/3ycy/home"/>
<Route author="luyuhuang" example="/3ycy/home" path="/3ycy/home" radar="1"/>
## 鼠绘漫画

View File

@ -33,12 +33,21 @@ module.exports = async (ctx) => {
const res = await got({ method: 'get', url: url.resolve(root_url, link) });
const content = cheerio.load(res.data);
const post = content('div.postBody');
post.find('img[data-src]').each((_, ele) => {
ele = content(ele);
ele.attr('src', ele.attr('data-src'));
ele.attr('alt', title.text());
ele.attr('title', title.text());
ele.removeAttr('class');
ele.removeAttr('data-src');
});
return {
title: title.text(),
link: link,
pubDate: pubDate,
description: content('div.postBody').html(),
description: post.html(),
};
});
})