feat: better reading experience for nyt & solidot (#6042)

This commit is contained in:
Enoch Ma
2020-10-29 17:03:01 +00:00
committed by GitHub
parent 3d59aced4a
commit 282d9ec931
3 changed files with 15 additions and 3 deletions
+4 -1
View File
@@ -82,7 +82,10 @@ module.exports = async (ctx) => {
const result = utils.ProcessFeed(response, hasEnVersion);
single.description = result.description;
const matching = '<div class="article-paragraph">';
const formatted = '<p></p>' + matching;
single.description = result.description.split(matching).join(formatted);
if (hasEnVersion) {
single.title = result.title;
+10 -2
View File
@@ -32,13 +32,21 @@ module.exports = async (ctx) => {
});
item.pubDate = result.pubDate;
item.description = result.description;
// Match 感谢|謝.*?cn.letters@nytimes.com。
const ending = /&#x611F;(&#x8C22|&#x8B1D);.*?cn\.letters@nytimes\.com&#x3002;/g;
const matching = '<div class="article-paragraph">';
const formatted = '<p></p>' + matching;
item.description = result.description.replace(ending, '').split(matching).join(formatted);
return Promise.resolve(item);
})
);
ctx.state.data = {
title: '纽约时报 每日简报',
title: '纽约时报中文网|每日简报',
link: url,
item: items,
};
+1
View File
@@ -37,6 +37,7 @@ module.exports = async function get_article(url) {
link: url,
description: $('div.p_mainnew')
.html()
.replace(/(href.*?)<u>(.*?)<\/u>/g, `$1$2`)
.replace(/href="\//g, 'href="' + domain + '/'),
category: $('div.icon_float > a').attr('title'),
};