Skip to content

Commit

Permalink
fix(routes/huxiu/briefcolumn): fix when img is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cscnk52 committed Feb 21, 2025
1 parent a4aa62a commit b8ad45f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/routes/huxiu/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ const cleanUpHTML = (data) => {
$('em.vote__bar, div.vote__btn, div.vote__time').remove();
$('p img').each((_, e) => {
e = $(e);
e.parent().replaceWith(
art(path.join(__dirname, 'templates/description.art'), {
image: {
src: (e.prop('src') ?? e.prop('_src')).split(/\?/)[0],
width: e.prop('data-w'),
height: e.prop('data-h'),
},
})
);
if ((e.prop('src') ?? e.prop('_src')) !== undefined) {
e.parent().replaceWith(
art(path.join(__dirname, 'templates/description.art'), {
image: {
src: (e.prop('src') ?? e.prop('_src')).split(/\?/)[0],
width: e.prop('data-w'),
height: e.prop('data-h'),
},
})
);
}
});
$('p, span').each((_, e) => {
e = $(e);
Expand Down

0 comments on commit b8ad45f

Please sign in to comment.