Skip to content

Instantly share code, notes, and snippets.

@Thiruppathi
Created June 4, 2018 10:44
Show Gist options
  • Save Thiruppathi/b0a267f27d782572c1f385d07cb4f8db to your computer and use it in GitHub Desktop.
Save Thiruppathi/b0a267f27d782572c1f385d07cb4f8db to your computer and use it in GitHub Desktop.
/*
[![Lighthouse score: 93/100](https://lighthouse-badge.appspot.com/?score=93&compact&category=Performance)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&compact&category=A11y)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 94/100](https://lighthouse-badge.appspot.com/?score=94&compact&category=BestPractices)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 89/100](https://lighthouse-badge.appspot.com/?score=89&compact&category=SEO)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 73/100](https://lighthouse-badge.appspot.com/?score=73&compact&category=PWA)](https://github.com/ebidel/lighthouse-badge)
*/
// let compactTemplate = `[![Lighthouse score: ${score}/100](https://lighthouse-badge.appspot.com/?score=${score}&${size}&category=${category})]`;
let myScores = {
Performance: 98,
PWA: 100,
A11y: 90,
BestPractices: 94,
SEO: 89
};
let projectUrl = "https://github.com/thiruppathi/lighthouse-badge";
generateMdBadge = (category = "", score, size = "") => {
return `[![Lighthouse score: ${score}/100](https://lighthouse-badge.appspot.com/?score=${score}&${size}&category=${category})](${projectUrl})`;
};
generateHtmlBadge = (category = "", score, size = "") => {
return `<a href="${projectUrl}" target="_blank">
<img src="https://lighthouse-badge.appspot.com?${score}&${size}&category=${category}">
</a>`;
};
generateBadges = myScores => {
Object.entries(myScores).forEach(([key, value]) => {
console.log(generateMdBadge(key, value, "compact"));
console.log(generateHtmlBadge(key, value, "compact").toString());
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment