fix: 过滤端传媒 API 返回空值 (#5935)

This commit is contained in:
Henry Wang
2020-10-18 21:05:11 +01:00
committed by GitHub
parent 396c2295c2
commit fcceb6e154
+14 -11
View File
@@ -157,17 +157,20 @@ module.exports = async (ctx) => {
};
const items = await Promise.all(
articles.slice(0, token === 'Basic YW5vbnltb3VzOkdpQ2VMRWp4bnFCY1ZwbnA2Y0xzVXZKaWV2dlJRY0FYTHY=' && key.iapReceipt === undefined ? 10 : articles.length).map(async (item) => ({
title: item.article.headline,
author: item.article.authors.length > 0 ? item.article.authors.map((x) => x.name).toString() : item.article.byline,
category: item.article.channels.filter((x) => !x.homepage).map((x) => x.name),
description: await getFullText(item.article.slug),
link: resolve_url('https://theinitium.com', item.article.url),
pubDate: item.article.date,
updated: item.article.updated,
// 如果遇到编辑部漏录入情况,则给uuid做个手脚,以便阅读器到时重抓。
guid: (await getFullText(item.article.slug)).endsWith('内容为空,请稍后再来') ? item.article.uuid + '-I-am-empty' : item.article.uuid,
}))
articles
.filter((a) => a.article)
.slice(0, token === 'Basic YW5vbnltb3VzOkdpQ2VMRWp4bnFCY1ZwbnA2Y0xzVXZKaWV2dlJRY0FYTHY=' && key.iapReceipt === undefined ? 10 : articles.length)
.map(async (item) => ({
title: item.article.headline,
author: item.article.authors.length > 0 ? item.article.authors.map((x) => x.name).toString() : item.article.byline,
category: item.article.channels.filter((x) => !x.homepage).map((x) => x.name),
description: await getFullText(item.article.slug),
link: resolve_url('https://theinitium.com', item.article.url),
pubDate: item.article.date,
updated: item.article.updated,
// 如果遇到编辑部漏录入情况,则给uuid做个手脚,以便阅读器到时重抓。
guid: (await getFullText(item.article.slug)).endsWith('内容为空,请稍后再来') ? item.article.uuid + '-I-am-empty' : item.article.uuid,
}))
);
ctx.state.data = {