feat(route/infoq): add article cover url (#21608)
* feat(route/infoq): add article cover url * feat(route/infoq): move cover image to description * fix: fix code format issue * fix: remove unused whitespace
This commit is contained in:
@@ -22,10 +22,11 @@ const ProcessFeed = async (list, cache) => {
|
||||
const author = data.author ? data.author.map((p) => p.nickname).join(',') : data.no_author;
|
||||
const category = [...e.topic.map((t) => t.name), ...e.label.map((l) => l.name)];
|
||||
const content = data.content_url ? (await got(data.content_url)).body : data.content;
|
||||
const description = addCoverToDescription(parseContent(content), data.article_cover);
|
||||
|
||||
return {
|
||||
title: data.article_title,
|
||||
description: parseContent(content),
|
||||
description,
|
||||
pubDate: parseDate(e.publish_time, 'x'),
|
||||
category,
|
||||
author,
|
||||
@@ -97,6 +98,10 @@ const parseToSimpleTexts = (content) =>
|
||||
return parseToSimpleText(i.content);
|
||||
});
|
||||
|
||||
function addCoverToDescription(content, cover) {
|
||||
return `<p><img src="${cover}"></p>${content}`;
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
const isRichContent = content.startsWith(`{"`);
|
||||
if (!isRichContent) {
|
||||
|
||||
Reference in New Issue
Block a user