mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1export const extractTwitterMeta = ({
2 pathname,
3}: {
4 pathname: string
5}): Record<string, string> => {
6 const res = {title: 'Twitter'}
7 const parsedPathname = pathname.split('/')
8 if (parsedPathname.length <= 1 || parsedPathname[1].length <= 1) {
9 // Excluding one letter usernames as they're reserved by twitter for things like cases like twitter.com/i/articles/follows/-1675653703
10 return res
11 }
12 const username = parsedPathname?.[1]
13 const isUserProfile = parsedPathname?.length === 2
14
15 res.title = isUserProfile
16 ? `@${username} on Twitter`
17 : `Tweet by @${username}`
18
19 return res
20}