Re-fetch GitHub stars after ViewTransitions navigation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Advait Paliwal
2026-03-24 16:32:38 -07:00
parent 3d84624011
commit 2aa4c84ce5

View File

@@ -218,17 +218,20 @@ const terminalCommands = [
initCopyBtn() initCopyBtn()
document.addEventListener("astro:after-swap", initCopyBtn) document.addEventListener("astro:after-swap", initCopyBtn)
fetch("https://api.github.com/repos/getcompanion-ai/feynman") function fetchStars() {
.then(function(r) { return r.json() }) var el = document.getElementById("star-count")
.then(function(d) { if (!el) return
if (d.stargazers_count !== undefined) { fetch("https://api.github.com/repos/getcompanion-ai/feynman")
var el = document.getElementById("star-count") .then(function(r) { return r.json() })
if (el) { .then(function(d) {
if (d.stargazers_count !== undefined) {
el.textContent = d.stargazers_count >= 1000 ? (d.stargazers_count / 1000).toFixed(1) + "k" : String(d.stargazers_count) el.textContent = d.stargazers_count >= 1000 ? (d.stargazers_count / 1000).toFixed(1) + "k" : String(d.stargazers_count)
var badge = document.getElementById("star-badge") var badge = document.getElementById("star-badge")
if (badge) badge.classList.remove("hidden") if (badge) badge.classList.remove("hidden")
} }
} })
}) .catch(function() {})
.catch(function() {}) }
fetchStars()
document.addEventListener("astro:after-swap", fetchStars)
</script> </script>