fix(route): gamme lazy load img

This commit is contained in:
Tony 2022-09-06 19:37:49 +00:00
parent 5ac511199d
commit ab2765a9fa
2 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,13 @@ module.exports = async (ctx) => {
const { data } = await got(item.link);
const $ = cheerio.load(data);
$('.entry img').each((_, img) => {
if (img.attribs['data-original']) {
img.attribs.src = img.attribs['data-original'];
delete img.attribs['data-original'];
}
});
item.author = $('.author_name').text().trim();
item.category = $('.tags a')
.toArray()

View File

@ -26,6 +26,13 @@ module.exports = async (ctx) => {
const { data } = await got(item.link);
const $ = cheerio.load(data);
$('.entry img').each((_, img) => {
if (img.attribs['data-original']) {
img.attribs.src = img.attribs['data-original'];
delete img.attribs['data-original'];
}
});
item.author = $('.author_name').text().trim();
item.category = $('.tags a')
.toArray()