Fix copy button surviving ViewTransitions with astro:after-swap rebind
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -197,21 +197,26 @@ const terminalCommands = [
|
||||
</Layout>
|
||||
|
||||
<script is:inline>
|
||||
;(function () {
|
||||
function initCopyBtn() {
|
||||
var btn = document.getElementById("install-cmd")
|
||||
if (btn) btn.addEventListener("click", function () {
|
||||
navigator.clipboard.writeText("curl -fsSL https://feynman.is/install | bash").then(function () {
|
||||
var copyIcon = document.getElementById("copy-icon")
|
||||
var checkIcon = document.getElementById("check-icon")
|
||||
copyIcon.classList.add("hidden")
|
||||
checkIcon.classList.remove("hidden")
|
||||
setTimeout(function () {
|
||||
copyIcon.classList.remove("hidden")
|
||||
checkIcon.classList.add("hidden")
|
||||
}, 2000)
|
||||
if (btn && !btn._bound) {
|
||||
btn._bound = true
|
||||
btn.addEventListener("click", function () {
|
||||
navigator.clipboard.writeText("curl -fsSL https://feynman.is/install | bash").then(function () {
|
||||
var copyIcon = document.getElementById("copy-icon")
|
||||
var checkIcon = document.getElementById("check-icon")
|
||||
copyIcon.classList.add("hidden")
|
||||
checkIcon.classList.remove("hidden")
|
||||
setTimeout(function () {
|
||||
copyIcon.classList.remove("hidden")
|
||||
checkIcon.classList.add("hidden")
|
||||
}, 2000)
|
||||
})
|
||||
})
|
||||
})
|
||||
})()
|
||||
}
|
||||
}
|
||||
initCopyBtn()
|
||||
document.addEventListener("astro:after-swap", initCopyBtn)
|
||||
|
||||
fetch("https://api.github.com/repos/getcompanion-ai/feynman")
|
||||
.then(function(r) { return r.json() })
|
||||
|
||||
Reference in New Issue
Block a user