Files
RSSHub/lib/v2/ifeng/utils.js
Fatpandac 259bcf1e5c fix(route): ifeng/feng this route is empty (#9372)
* ifeng/feng this route is empty

* refactor: migrate to v2

* fix: parseDate
2022-03-24 01:47:29 +08:00

29 lines
933 B
JavaScript

const extractDoc = (data) => {
if (data.docData.contentData.contentList) {
return extractContent(data.docData.contentData.contentList);
}
if (data.docData.contentData.image) {
return data.docData.contentData.image.map((item) => `<p><img src="${item.url}"><br>${item.description.replace(/\n/g, '<br>')}</p>`).join('');
}
};
const extractContent = (data) =>
(data || [])
.map((item) => {
const type = item.type;
if (type === 'video') {
return `<video src="${item.data.mobileUrl}" controls style="width:100%;height:100%"></video>`;
}
if (type === 'text') {
let temp = item.data;
temp = temp.replace(/data-lazyload=(.+?) src=(.+?) style=".+?"/g, 'src=$1');
return temp;
}
return '';
})
.join('<br>');
module.exports = {
extractDoc,
};