Skip to content

Commit

Permalink
feat: make url clickable (#14353)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttttmr authored Feb 5, 2024
1 parent b552dad commit c93226c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2/jike/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const cheerio = require('cheerio');
const dayjs = require('dayjs');
const { constructTopicEntry } = require('@/v2/jike/utils');

const urlRegex = /(https?:\/\/[^\s"'<>]+)/g;

module.exports = async (ctx) => {
const id = ctx.params.id;
const topicUrl = `https://m.okjike.com/topics/${id}`;
Expand Down Expand Up @@ -33,6 +35,7 @@ module.exports = async (ctx) => {
return description;
});
}
item.description = item.description.replaceAll(urlRegex, (url) => `<a href="${url}">${url}</a>`);
item.title = `${data.topic.content} ${dayjs(one.pubDate).format('MM月DD日')}`;
return item;
})
Expand Down

0 comments on commit c93226c

Please sign in to comment.