MCPcopy Index your code
hub / github.com/github/awesome-copilot / renderHooksHtml

Function renderHooksHtml

website/src/scripts/pages/hooks-render.ts:37–90  ·  view source on GitHub ↗
(items: RenderableHook[])

Source from the content-addressed store, hash-verified

35}
36
37export function renderHooksHtml(items: RenderableHook[]): string {
38 if (items.length === 0) {
39 return renderEmptyStateHtml("No hooks found", "Try adjusting the selected filters.");
40 }
41
42 return items
43 .map((item) => {
44 const metaHtml = `
45 ${item.hooks
46 .map(
47 (hook) => `<span class="resource-tag tag-hook">${escapeHtml(hook)}</span>`
48 )
49 .join("")}
50 ${item.tags
51 .map((tag) => `<span class="resource-tag tag-tag">${escapeHtml(tag)}</span>`)
52 .join("")}
53 ${
54 item.assets.length > 0
55 ? `<span class="resource-tag tag-assets">${item.assets.length} asset${
56 item.assets.length === 1 ? "" : "s"
57 }</span>`
58 : ""
59 }
60 ${getLastUpdatedHtml(item.lastUpdated)}
61 `;
62
63 const actionsHtml = `
64 <button class="btn btn-primary download-hook-btn" data-hook-id="${escapeHtml(
65 item.id
66 )}" title="Download as ZIP">
67 <svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor">
68 <path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
69 <path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
70 </svg>
71 Download
72 </button>
73 <a href="${getGitHubUrl(
74 item.path
75 )}" class="btn btn-secondary" target="_blank" onclick="event.stopPropagation()" title="View on GitHub">GitHub</a>
76 `;
77
78 return renderSharedCardHtml({
79 title: item.title,
80 description: item.description || "No description",
81 articleAttributes: {
82 "data-path": item.readmeFile,
83 "data-hook-id": item.id,
84 },
85 metaHtml,
86 actionsHtml,
87 });
88 })
89 .join("");
90}

Callers 1

renderItemsFunction · 0.90

Calls 5

renderEmptyStateHtmlFunction · 0.90
escapeHtmlFunction · 0.90
getLastUpdatedHtmlFunction · 0.90
getGitHubUrlFunction · 0.90
renderSharedCardHtmlFunction · 0.90

Tested by

no test coverage detected