Files
RSSHub/lib/routes/ifeng/utils.js
T
2024-03-01 01:24:49 +08:00

27 lines
651 B
JavaScript

import { art } from '@/utils/render';
import * as path from 'node:path';
const extractDoc = (data) =>
data
.map((item) => {
const type = item.type;
if (type === 'video') {
return renderVideo(item.data);
}
if (type === 'text') {
return item.data.replaceAll(/data-lazyload=(.+?) src=(.+?) style=".+?"/g, 'src=$1');
}
return '';
})
.join('<br>');
const renderVideo = (videoInfo) =>
art(path.join(__dirname, 'templates/video.art'), {
videoInfo,
});
module.exports = {
extractDoc,
renderVideo,
};