feat(route): add slowmist news (#10044)

* feat(route): add slowmist news

* feat(utils): remove useless ul for code section

* docs: add slowmist news route docs

* docs(quick-start): new router under /lib/v2

* test(utils): add test fixArticleContent for new wechat-mp code

* feat(router): update radar source of slowmist
This commit is contained in:
Atlas Quan
2022-07-04 23:44:58 +08:00
committed by GitHub
parent 8f8adfb4b2
commit bd80574f76
7 changed files with 101 additions and 7 deletions

View File

@@ -104,6 +104,14 @@ const fixArticleContent = (html, skipImg = false) => {
}
});
// add breaks in code section
$('code').each((_, code) => {
$('<br>').insertAfter(code);
});
// clear line index tags in code section
$('.code-snippet__line-index').remove();
// fix single picture article
// example: https://mp.weixin.qq.com/s/4p5YmYuASiQSYFiy7KqydQ
$('script').each((_, script) => {
@@ -186,7 +194,6 @@ const fetchArticle = async (ctx, url, bypassHostCheck = false) => {
let summary = $('meta[name=description]').attr('content');
summary = summary !== title ? summary : '';
let description = fixArticleContent($('#js_content'));
// No article get or article is too short, try the original url
const originalUrl = detectOriginalArticleUrl($);
if (originalUrl) {
@@ -211,7 +218,6 @@ const fetchArticle = async (ctx, url, bypassHostCheck = false) => {
let mpName = $('.profile_nickname').first().text();
mpName = mpName && mpName.trim();
return { title, author, description, summary, pubDate, mpName, link: url };
});
};