MCPcopy Create free account
hub / github.com/dailydotdev/apps / buildComments

Function buildComments

packages/webapp/lib/postMarkdown.ts:467–498  ·  view source on GitHub ↗
(comments: Comment[])

Source from the content-addressed store, hash-verified

465};
466
467const buildComments = (comments: Comment[]): string[] => {
468 const usable = comments
469 .map((comment) => ({ comment, body: comment.content?.trim() ?? '' }))
470 .filter(({ body }) => !!body);
471
472 if (!usable.length) {
473 return [];
474 }
475
476 const lines = [
477 '## Community discussion',
478 '',
479 'Top comments from developers on daily.dev.',
480 '',
481 ];
482
483 usable.forEach(({ comment, body }) => {
484 const handle = comment.author?.username
485 ? `@${comment.author.username}`
486 : comment.author?.name || 'A daily.dev member';
487 lines.push(
488 `**${escapeMarkdown(handle)}** · ${comment.numUpvotes ?? 0} upvotes`,
489 );
490 lines.push('');
491 truncateAtWordBoundary(body, MAX_COMMENT_LENGTH)
492 .split('\n')
493 .forEach((line) => lines.push(`> ${line}`.trimEnd()));
494 lines.push('');
495 });
496
497 return lines;
498};
499
500const buildSimilarPosts = (posts: SimilarPost[]): string[] => {
501 if (!posts.length) {

Callers 1

buildPostMarkdownFunction · 0.85

Calls 3

escapeMarkdownFunction · 0.90
truncateAtWordBoundaryFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected