diff --git a/www/src/components/navigation/AskAIButton.tsx b/www/src/components/navigation/AskAIButton.tsx
new file mode 100644
index 0000000000..b86ed97b98
--- /dev/null
+++ b/www/src/components/navigation/AskAIButton.tsx
@@ -0,0 +1,33 @@
+export default function AskAIButton() {
+ const handleClick = () => {
+ window.SiteAssist?.("toggle");
+ };
+
+ return (
+
+ );
+}
diff --git a/www/src/components/navigation/navbar.astro b/www/src/components/navigation/navbar.astro
index f0644e0b09..a907c566e4 100644
--- a/www/src/components/navigation/navbar.astro
+++ b/www/src/components/navigation/navbar.astro
@@ -1,5 +1,6 @@
---
import { getIsRtlFromUrl, getLanguageFromURL } from "../../languages";
+import AskAIButton from "./AskAIButton";
import GithubIcon from "./githubIcon.astro";
import LanguageSelect from "./LanguageSelect";
import Search from "./Search";
@@ -103,12 +104,13 @@ const navbarLinks: Array<{ href: string; label: string }> = [
>
-
-
-
+
+
+
+
diff --git a/www/src/components/navigation/themeToggleButton.astro b/www/src/components/navigation/themeToggleButton.astro
index cfa2898d66..51f7232e10 100644
--- a/www/src/components/navigation/themeToggleButton.astro
+++ b/www/src/components/navigation/themeToggleButton.astro
@@ -47,6 +47,11 @@
html.classList.contains("dark") ? "dark" : "light",
);
+ window.SiteAssist?.(
+ "changeTheme",
+ html.classList.contains("dark") ? "dark" : "light",
+ );
+
const toggleTheme = (t: "light" | "dark") => {
localStorage.setItem("theme", t);
html.classList.add(t === "dark" ? "dark" : "light");
@@ -54,6 +59,8 @@
themeToggle!.setAttribute("title", getMessage());
themeToggle!.setAttribute("aria-label", getMessage());
themeToggle!.setAttribute("value", t);
+
+ window.SiteAssist?.("changeTheme", t);
};
themeToggle!.addEventListener("click", () => {
diff --git a/www/src/layouts/docs.astro b/www/src/layouts/docs.astro
index e1974083d8..0e00aa76fe 100644
--- a/www/src/layouts/docs.astro
+++ b/www/src/layouts/docs.astro
@@ -65,10 +65,36 @@ const githubEditUrl = `${CONFIG.GITHUB_EDIT_URL}/${currentFile}`;
html.classList.remove("light");
}
+
+
+
+
+
+
+
+
+
+
;
+}
+
+export type CommandQueueItem =
+ | ["init", InitOptions]
+ | ["identify", IdentifyPayload]
+ | ["changeTheme", Theme]
+ | ["open"]
+ | ["close"]
+ | ["toggle"]
+ | ["track", string, any?];
+
+export type CommandKey = CommandQueueItem[0];
+
+export interface SiteAssistAPI {
+ (cmd: "init", opts: InitOptions): void;
+ (cmd: "identify", user: IdentifyPayload): void;
+ (cmd: "changeTheme", theme: Theme): void;
+ (cmd: "track", event: string, data?: any): void;
+ (cmd: "open"): void;
+ (cmd: "close"): void;
+ (cmd: "toggle"): void;
+ /** Temp queue set by the stub; cleared once the real API takes over. */
+ _q?: CommandQueueItem[];
+}
+
+declare global {
+ interface Window {
+ SiteAssist?: SiteAssistAPI;
+ }
+}