Re-fetch GitHub stars after ViewTransitions navigation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user