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