Skip to content

Commit

Permalink
feat(route): bilibili 动态路由新增:将话题作为 category (#15741)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed May 28, 2024
1 parent 6e71b1a commit 77501fd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/routes/bilibili/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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] || '');
}
}
}

Expand Down Expand Up @@ -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,
};
})
);
Expand Down

0 comments on commit 77501fd

Please sign in to comment.