From 458fd193fe3c83e93e21de13c266cf2c4f143e7e Mon Sep 17 00:00:00 2001 From: OKAN TIKTAS Date: Wed, 28 Oct 2026 15:53:23 -0400 Subject: [PATCH] docs(site): add Python installation command (#480) --- site/src/index.njk | 25 +++++++++++--- site/src/js/interactivity.js | 63 ++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/site/src/index.njk b/site/src/index.njk index f35883a1..ac6ee928 100644 --- a/site/src/index.njk +++ b/site/src/index.njk @@ -14,12 +14,29 @@ layout: base
Docs GitHub +
-
- npm install typechat - + +
+

JavaScript / TypeScript

+
+ npm install typechat + +
+
+ +
+

Python

+
+ pip install typechat + +
- + \ No newline at end of file diff --git a/site/src/js/interactivity.js b/site/src/js/interactivity.js index ec2945da..fd6d28fa 100644 --- a/site/src/js/interactivity.js +++ b/site/src/js/interactivity.js @@ -1,38 +1,51 @@ // @ts-check { - /** @type {any} */ - let lastTimeout; - - /** @type {HTMLButtonElement | null} */ - const copyButton = document.querySelector(".typechat-code-copy button"); - copyButton?.addEventListener("click", async () => { - clearTimeout(lastTimeout); - try { - await navigator.clipboard.writeText("npm install typechat"); - copyButton.textContent = "✅"; - copyButton.title = copyButton.ariaLabel = "Command copied." - } - catch { - copyButton.textContent = "❌"; - copyButton.title = copyButton.ariaLabel = "Error copying." + const copyContainers = document.querySelectorAll(".typechat-code-copy"); + + for (const container of copyContainers) { + const copyButton = container.querySelector("button"); + const command = container.querySelector("code")?.textContent?.trim(); + + if (!copyButton || !command) { + continue; } - lastTimeout = setTimeout(() => { - copyButton.textContent = "📋"; - copyButton.title = copyButton.ariaLabel = "Copy 'npm install' command." - }, 1500); - }); + + /** @type {ReturnType | undefined} */ + let lastTimeout; + + copyButton.addEventListener("click", async () => { + clearTimeout(lastTimeout); + + try { + await navigator.clipboard.writeText(command); + + copyButton.textContent = "\u2705"; + copyButton.title = copyButton.ariaLabel = "Command copied."; + } catch { + copyButton.textContent = "\u274C"; + copyButton.title = copyButton.ariaLabel = "Error copying."; + } + + lastTimeout = setTimeout(() => { + copyButton.textContent = "\u{1F4CB}"; + copyButton.title = copyButton.ariaLabel = + `Copy ${command} command.`; + }, 1500); + }); + } } { - const selectElements = /** @type {HTMLCollectionOf} */ (document.getElementsByClassName("nav-on-change")); + const selectElements = /** @type {HTMLCollectionOf} */ ( + document.getElementsByClassName("nav-on-change") + ); + for (const select of selectElements) { const change = () => { window.location.pathname = select.value; }; + select.onchange = change; - // if (select.options.length === 1 && window.location.pathname !== select.value) { - // change(); - // } } -} +} \ No newline at end of file