({
isSubDomainRouting,
channelName,
settings,
thread,
}: {
isSubDomainRouting: boolean;
channelName: string;
settings: Settings;
thread: SerializedThread;
})
| 4 | import { replaceMentions } from './utils/replaceMentions'; |
| 5 | |
| 6 | export function buildThreadSeo({ |
| 7 | isSubDomainRouting, |
| 8 | channelName, |
| 9 | settings, |
| 10 | thread, |
| 11 | }: { |
| 12 | isSubDomainRouting: boolean; |
| 13 | channelName: string; |
| 14 | settings: Settings; |
| 15 | thread: SerializedThread; |
| 16 | }) { |
| 17 | const firstMessage = thread.messages.find(Boolean); |
| 18 | const cleanBody = normalize( |
| 19 | replaceMentions({ |
| 20 | body: firstMessage?.body || thread.slug, |
| 21 | mentions: firstMessage?.mentions || [], |
| 22 | }) |
| 23 | ); |
| 24 | const title = [ |
| 25 | thread.title || cleanBody.slice(0, 60), |
| 26 | settings.communityName, |
| 27 | '#' + channelName, |
| 28 | ] |
| 29 | .filter(Boolean) |
| 30 | .join(' '); |
| 31 | |
| 32 | const url = buildUrl(isSubDomainRouting, settings, thread); |
| 33 | |
| 34 | return { |
| 35 | title, |
| 36 | description: cleanBody.slice(0, 200), |
| 37 | image: settings.logoUrl, |
| 38 | url, |
| 39 | robotsMetaTag: thread.robotsMetaTag, |
| 40 | }; |
| 41 | } |
no test coverage detected