MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / buildNameText

Function buildNameText

apps/web/utilities/seo/buildStructureData.tsx:8–44  ·  view source on GitHub ↗
(thread: SerializedThread, url: string)

Source from the content-addressed store, hash-verified

6import { parseDate } from './utils/parseDate';
7
8function buildNameText(thread: SerializedThread, url: string): Question {
9 const first = thread.messages[0];
10 const cleanBody = normalize(
11 replaceMentions({ body: first.body, mentions: first.mentions })
12 ).trim();
13
14 const suggestedAnswers = thread.messages
15 .slice(1)
16 .map((message) => {
17 return {
18 url: `${url}#${message.id}`,
19 text: normalize(
20 replaceMentions({ body: message.body, mentions: message.mentions })
21 ).trim(),
22 author: {
23 name: message.author?.displayName || 'user',
24 },
25 dateCreated: parseDate(message.sentAt),
26 };
27 })
28 .filter((m) => !!m.text);
29
30 return {
31 name:
32 !!thread.title && !!thread.title.trim()
33 ? thread.title.trim()
34 : cleanBody.substring(0, 60),
35 text: cleanBody,
36 author: {
37 name: first.author?.displayName || 'user',
38 },
39 upvoteCount: thread.viewCount,
40 dateCreated: parseDate(first.sentAt),
41 answerCount: suggestedAnswers.length,
42 suggestedAnswer: suggestedAnswers,
43 };
44}
45
46export function buildStructureData({
47 thread,

Callers 1

buildStructureDataFunction · 0.85

Calls 4

normalizeFunction · 0.90
replaceMentionsFunction · 0.90
parseDateFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected