commit 3f4b31a5f9b54046c5e919285959d854baf58337
parent 9085c7aa39c574d16cec008a41ed3c7b195eb224
Author: Amit Dutta <mail@amit.is-a.dev>
Date: Fri, 31 Jul 2026 18:36:23 +0530
Merge pull request #19 from notamitgamer/edit-20260731-183556
added ask ai again
Diffstat:
2 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts
@@ -1,4 +1,4 @@
-import { h, Fragment } from 'vue'
+import { h, Fragment, onMounted } from 'vue'
import DefaultTheme from 'vitepress/theme'
import type { Theme } from 'vitepress'
import Banner from './components/Banner.vue'
@@ -25,5 +25,44 @@ export default {
'doc-after': () => h(Footer),
'nav-bar-content-after': () => h(SponsorButton)
})
+ },
+
+ setup() {
+ onMounted(() => {
+ // Small delay to ensure VitePress has rendered the navbar button
+ setTimeout(() => {
+ // Target the search/ask AI button
+ const searchBtn = document.querySelector('.DocSearch-Button');
+ if (!searchBtn) return;
+
+ // When clicked, add the loading spinner
+ searchBtn.addEventListener('click', () => {
+ // If the modal is already in the DOM, no need for the spinner
+ if (!document.querySelector('.DocSearch-Container')) {
+ searchBtn.classList.add('is-loading');
+ }
+ });
+
+ // Watch the page to see when the modal finishes downloading and appears
+ const observer = new MutationObserver((mutations) => {
+ for (const mutation of mutations) {
+ if (mutation.addedNodes.length) {
+ // Check if the added node is the Algolia modal container
+ const isModalAdded = Array.from(mutation.addedNodes).some(
+ (node: any) => node.classList && node.classList.contains('DocSearch-Container')
+ );
+
+ // If the modal is added, remove the loading state
+ if (isModalAdded) {
+ searchBtn.classList.remove('is-loading');
+ }
+ }
+ }
+ });
+
+ // Start observing the body for injected elements
+ observer.observe(document.body, { childList: true, subtree: true });
+ }, 500);
+ })
}
} satisfies Theme
\ No newline at end of file
diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css
@@ -413,4 +413,52 @@
--vp-button-brand-bg: var(--vp-c-brand-1);
--vp-button-brand-hover-bg: var(--vp-c-brand-2);
--vp-button-brand-active-bg: var(--vp-c-brand-1);
+}
+
+/* ==========================================================================
+ FORCE FONT ON DOCSEARCH & AI MODALS
+ ========================================================================== */
+.DocSearch-Container,
+.DocSearch-Container *,
+.DocSearch-Modal,
+.DocSearch-Modal * {
+ font-family: var(--vp-font-family-base) !important;
+}
+
+/* ==========================================================================
+ SEARCH BUTTON LOADING STATE
+ ========================================================================== */
+
+/* Hide the default icon when loading */
+.DocSearch-Button.is-loading .DocSearch-Search-Icon {
+ display: none !important;
+}
+
+/* Create the spinning animation */
+.DocSearch-Button.is-loading::before {
+ content: "";
+ display: inline-block;
+ width: 16px;
+ height: 16px;
+ border: 2px solid var(--vp-c-text-3);
+ border-top-color: var(--vp-c-brand-1); /* Uses the Peach color */
+ border-radius: 50%;
+ animation: docsearch-spin 0.8s linear infinite;
+ margin-right: 8px; /* Spaces it exactly like the original icon */
+}
+
+@keyframes docsearch-spin {
+ to { transform: rotate(360deg); }
+}
+
+/* ==========================================================================
+ FORCE FONT ON DOCSEARCH & ASK AI MODALS
+ ========================================================================== */
+.DocSearch-Portal * {
+ font-family: var(--vp-font-family-base) !important;
+}
+
+/* Fallback just in case standard container is used */
+.DocSearch-Container * {
+ font-family: var(--vp-font-family-base) !important;
}
\ No newline at end of file