(items: RenderablePlugin[])
| 57 | } |
| 58 | |
| 59 | export function renderPluginsHtml(items: RenderablePlugin[]): string { |
| 60 | if (items.length === 0) { |
| 61 | return renderEmptyStateHtml('No plugins found', 'Try different tags or clear the current filters'); |
| 62 | } |
| 63 | |
| 64 | return items |
| 65 | .map((item) => { |
| 66 | const isExternal = item.external === true; |
| 67 | const metaTag = isExternal |
| 68 | ? '<span class="resource-tag resource-tag-external">🔗 External</span>' |
| 69 | : `<span class="resource-tag">${item.itemCount} items</span>`; |
| 70 | const authorTag = |
| 71 | isExternal && item.author?.name |
| 72 | ? `<span class="resource-tag">by ${escapeHtml(item.author.name)}</span>` |
| 73 | : ''; |
| 74 | const githubHref = isExternal |
| 75 | ? escapeHtml(getExternalPluginUrl(item)) |
| 76 | : getGitHubUrl(item.path); |
| 77 | const metaHtml = ` |
| 78 | ${metaTag} |
| 79 | ${authorTag} |
| 80 | ${item.tags?.slice(0, 4).map((tag) => `<span class="resource-tag">${escapeHtml(tag)}</span>`).join('') || ''} |
| 81 | ${item.tags && item.tags.length > 4 ? `<span class="resource-tag">+${item.tags.length - 4} more</span>` : ''} |
| 82 | `; |
| 83 | |
| 84 | const actionsHtml = ` |
| 85 | <a href="${githubHref}" class="btn btn-secondary" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()" title="${isExternal ? 'View repository' : 'View on GitHub'}">${isExternal ? 'Repository' : 'GitHub'}</a> |
| 86 | `; |
| 87 | |
| 88 | return renderSharedCardHtml({ |
| 89 | title: item.name, |
| 90 | description: item.description || 'No description', |
| 91 | articleClassName: isExternal ? 'resource-item-external' : '', |
| 92 | articleAttributes: { |
| 93 | 'data-path': item.path, |
| 94 | }, |
| 95 | metaHtml, |
| 96 | actionsHtml, |
| 97 | }); |
| 98 | }) |
| 99 | .join(''); |
| 100 | } |
no test coverage detected