feat(route): bilibili 动态路由新增:将话题作为 category (#15741)

This commit is contained in:
CaoMeiYouRen
2024-05-28 13:53:14 +08:00
committed by GitHub
parent 6e71b1a101
commit 77501fd043
+16 -1
View File
@@ -275,7 +275,7 @@ async function handler(ctx) {
let description = getDes(data) || '';
const title = getTitle(data) || description; // 没有 title 的时候使用 desc 填充
const category: string[] = [];
// emoji
if (data.module_dynamic?.desc?.rich_text_nodes?.length) {
const nodes = data.module_dynamic.desc.rich_text_nodes;
@@ -301,6 +301,20 @@ async function handler(ctx) {
.join('<br>')
);
}
if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') {
// 将话题作为 category
category.push(node.text.match(/#(\S+)#/)?.[1] || '');
}
}
}
if (data.module_dynamic?.major?.opus?.summary?.rich_text_nodes?.length) {
const nodes = data.module_dynamic.major.opus.summary.rich_text_nodes;
for (const node of nodes) {
if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') {
// 将话题作为 category
category.push(node.text.match(/#(\S+)#/)?.[1] || '');
}
}
}
@@ -353,6 +367,7 @@ async function handler(ctx) {
pubDate: data.module_author?.pub_ts ? parseDate(data.module_author.pub_ts, 'X') : undefined,
link,
author,
category: category.length ? category : undefined,
};
})
);