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

Function buildSimilarPosts

packages/webapp/lib/postMarkdown.ts:500–523  ·  view source on GitHub ↗
(posts: SimilarPost[])

Source from the content-addressed store, hash-verified

498};
499
500const buildSimilarPosts = (posts: SimilarPost[]): string[] => {
501 if (!posts.length) {
502 return [];
503 }
504
505 const lines = ['## Similar posts on daily.dev', ''];
506
507 posts.forEach((post) => {
508 const meta = [
509 post.source?.name ? escapeMarkdown(post.source.name) : undefined,
510 `${post.numUpvotes ?? 0} upvotes`,
511 `${post.numComments ?? 0} comments`,
512 ].filter(Boolean);
513 lines.push(
514 `- [${escapeMarkdown(post.title || 'Untitled')}](${postUrl(
515 post,
516 )}) · ${meta.join(' · ')}`,
517 );
518 });
519
520 lines.push('');
521
522 return lines;
523};
524
525const buildFooter = (post: PostMarkdownPost): string[] => {
526 const lines = ['---', ''];

Callers 1

buildPostMarkdownFunction · 0.85

Calls 3

escapeMarkdownFunction · 0.90
postUrlFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected