Better formatting of tweet titles

This commit is contained in:
Jackson Harper
2023-04-25 09:47:52 +08:00
parent e943f91acf
commit 53e81cc06e
2 changed files with 3 additions and 3 deletions

Binary file not shown.

View File

@ -134,8 +134,8 @@ const getTweetsByIds = async (ids: string[]): Promise<Tweets> => {
return response.data
}
const titleForAuthor = (author: { name: string }) => {
return `${author.name} on Twitter`
const titleForTweet = (author: { name: string }, text: string) => {
return `${author.name} on Twitter: ${text.replace(/http\S+/, '')}`
}
const tweetIdFromStatusUrl = (url: string): string | undefined => {
@ -319,7 +319,7 @@ export class TwitterHandler extends ContentHandler {
const authorId = tweetData.author_id
const author = tweet.includes.users.filter((u) => (u.id = authorId))[0]
// escape html entities in title
const title = titleForAuthor(author)
const title = titleForTweet(author, tweetData.text)
const escapedTitle = _.escape(title)
const authorImage = author.profile_image_url.replace('_normal', '_400x400')
const description = _.escape(tweetData.text)