* Generate HTML for a single entry * @param {object} entry - Parsed YAML data * @returns {string} HTML string for the details element
(entry)
| 32 | * @returns {string} HTML string for the details element |
| 33 | */ |
| 34 | function generateEntryHtml(entry) { |
| 35 | // Determine link text based on URL type first |
| 36 | let linkText = '🔗 <b>View Repository</b>'; |
| 37 | if (entry.repo.includes('gist.github.com')) { |
| 38 | linkText = '🔗 <b>View Gist</b>'; |
| 39 | } else if (entry.repo.includes('/discussions/')) { |
| 40 | linkText = '🔗 <b>View Discussion</b>'; |
| 41 | } |
| 42 | |
| 43 | // Extract owner/repo from URL for star badge (only for non-gist, non-discussion GitHub repos) |
| 44 | // Use negative lookahead to exclude gist.github.com |
| 45 | const isGist = entry.repo.includes('gist.github.com'); |
| 46 | const isDiscussion = entry.repo.includes('/discussions/'); |
| 47 | const repoMatch = entry.repo.match(/github\.com\/(?!gist\.)([^\/]+)\/([^\/]+)/); |
| 48 | |
| 49 | let summaryContent = `<b>${entry.name}</b>`; |
| 50 | |
| 51 | // Add star badge if it's a GitHub repo (not a gist or discussion) |
| 52 | if (repoMatch && !isGist && !isDiscussion) { |
| 53 | const owner = repoMatch[1]; |
| 54 | const repo = repoMatch[2].replace(/\.git$/, '').replace(/\/$/, ''); |
| 55 | const starBadge = `https://badgen.net/github/stars/${owner}/${repo}`; |
| 56 | summaryContent += ` <img src="${starBadge}" height="14"/>`; |
| 57 | } |
| 58 | |
| 59 | summaryContent += ` - <i>${entry.tagline}</i>`; |
| 60 | |
| 61 | return `<details> |
| 62 | <summary>${summaryContent}</summary> |
| 63 | <blockquote> |
| 64 | ${entry.description} |
| 65 | <br><br> |
| 66 | <a href="${entry.repo}">${linkText}</a> |
| 67 | </blockquote> |
| 68 | </details>`; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Write the final README |
no outgoing calls
no test coverage detected