mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Truncate tweet text used in titles using lodash
This commit is contained in:
parent
2d648fcb6d
commit
155fad5b9c
2 changed files with 5 additions and 1 deletions
|
|
@ -31,6 +31,7 @@
|
|||
"addressparser": "^1.0.1",
|
||||
"axios": "^0.27.2",
|
||||
"linkedom": "^0.14.16",
|
||||
"lodash": "^4.17.21",
|
||||
"luxon": "^3.0.4",
|
||||
"puppeteer-core": "^19.1.1",
|
||||
"rfc2047": "^4.0.1",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { ContentHandler, PreHandleResult } from '../content-handler'
|
|||
import axios from 'axios'
|
||||
import { DateTime } from 'luxon'
|
||||
import _ from 'underscore'
|
||||
import { truncate } from 'lodash'
|
||||
import { Browser, BrowserContext } from 'puppeteer-core'
|
||||
|
||||
interface TweetIncludes {
|
||||
|
|
@ -135,7 +136,9 @@ const getTweetsByIds = async (ids: string[]): Promise<Tweets> => {
|
|||
}
|
||||
|
||||
const titleForTweet = (author: { name: string }, text: string) => {
|
||||
return `${author.name} on Twitter: ${text.replace(/http\S+/, '')}`
|
||||
return `${author.name} on Twitter: ${truncate(text.replace(/http\S+/, ''), {
|
||||
length: 100,
|
||||
})}`
|
||||
}
|
||||
|
||||
const tweetIdFromStatusUrl = (url: string): string | undefined => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue