(posts: SimilarPost[])
| 498 | }; |
| 499 | |
| 500 | const 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 | |
| 525 | const buildFooter = (post: PostMarkdownPost): string[] => { |
| 526 | const lines = ['---', '']; |
no test coverage detected