Skip to content

Instantly share code, notes, and snippets.

@guibranco
Last active December 15, 2023 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guibranco/9f017dc0ccfc555e9f3b3e557f111c22 to your computer and use it in GitHub Desktop.
Save guibranco/9f017dc0ccfc555e9f3b3e557f111c22 to your computer and use it in GitHub Desktop.
Generate HTML from repositories list from API response
const jsonData = pm.response.json();
const divPattern = "<div style=\"margin-top: 10px;\">";
const imageUrl = (item) => `https://github-readme-stats-guibranco.vercel.app/api/pin/?username=${item.organization.login}&amp;repo=${item.name}&amp;theme=dark&amp;bg_color=222222&amp;show_owner=true&amp;show_forks=false&amp;show_issues=true`;
const link = (item) => `<a href="${item.url}" target="_blank">${image(item)}</a>`;
const image = (item) => `<img style="min-height: 100px; padding-right: 10px;" src="${imageUrl(item)}" alt="${item.full_name}" />`;
var html = divPattern;
for(let i = 0; i < jsonData.length; i++){
html += link(jsonData[i]);
if(i % 2 !== 0){
html += "</div>" + divPattern;
}
}
html += "</div>";
console.log(html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment