From f75997f935d961d50a9595b466e7254bd9877a47 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:54:00 +0800 Subject: [PATCH] fix(route/tencent): Adapt to video pages. (#15328) --- lib/routes/tencent/news/author.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/routes/tencent/news/author.ts b/lib/routes/tencent/news/author.ts index c0bd95a0a19a7b..bb1169b4d673f9 100644 --- a/lib/routes/tencent/news/author.ts +++ b/lib/routes/tencent/news/author.ts @@ -68,17 +68,19 @@ async function handler(ctx) { .text() .match(/window\.DATA = ({.+});/)[1] ); - const $data = load(data.originContent.text, null, false); - - $data('*') - .contents() - .filter((_, elem) => elem.type === 'comment') - .replaceWith((_, elem) => - art(path.join(__dirname, '../templates/news/image.art'), { - attribute: elem.data.trim(), - originAttribute: data.originAttribute, - }) - ); + const $data = load(data.originContent?.text || '', null, false); + if ($data) { + // Not video page + $data('*') + .contents() + .filter((_, elem) => elem.type === 'comment') + .replaceWith((_, elem) => + art(path.join(__dirname, '../templates/news/image.art'), { + attribute: elem.data.trim(), + originAttribute: data.originAttribute, + }) + ); + } return { title,