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)
function fetchStars() {
var el = document.getElementById("star-count")
if (!el) return
fetch("https://api.github.com/repos/getcompanion-ai/feynman") fetch("https://api.github.com/repos/getcompanion-ai/feynman")
.then(function(r) { return r.json() }) .then(function(r) { return r.json() })
.then(function(d) { .then(function(d) {
if (d.stargazers_count !== undefined) { if (d.stargazers_count !== undefined) {
var el = document.getElementById("star-count")
if (el) {
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>