mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 15:47:38 +02:00
📚 Merge penpot/penpot-docs repository
This commit is contained in:
parent
3932054ea6
commit
88296480ec
665 changed files with 17621 additions and 0 deletions
30
docs/js/github-star.js
Normal file
30
docs/js/github-star.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
(function (window, document) {
|
||||
"use strict";
|
||||
|
||||
const getRepoStars = async () => {
|
||||
try {
|
||||
const response = await fetch("https://api.github.com/repos/penpot/penpot");
|
||||
const data = await response.json();
|
||||
return data.stargazers_count;
|
||||
} catch (error) {
|
||||
console.error("Error fetching repository data:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const updateStarsCount = async () => {
|
||||
const starsCount = await getRepoStars();
|
||||
if (starsCount !== null) {
|
||||
const starsEl = document.getElementById("repo-stars");
|
||||
if (starsEl) {
|
||||
starsEl.textContent = `${starsCount}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
updateStarsCount();
|
||||
});
|
||||
|
||||
})(window, document);
|
Loading…
Add table
Add a link
Reference in a new issue