Skip to content

Commit 5291ab2

Browse files
authored
Fix AI url format (#1035)
* ai and design tweak * fix web billing titles * overview fix * remove test * fix incorrect title formatting * useIsBrowser and default url * default * claude
1 parent f5ee3b9 commit 5291ab2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/components/AIToolsContainer/AIToolsContainer.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import styles from "./styles.module.css";
22
import useBaseUrl from "@docusaurus/useBaseUrl";
3+
import useIsBrowser from "@docusaurus/useIsBrowser";
4+
import { useState, useEffect } from "react";
35

46
type AIToolsContainerProps = {};
57

68
const AIToolsContainer = ({}: AIToolsContainerProps) => {
7-
const getCurrentUrl = () => {
8-
if (typeof window !== "undefined") {
9-
return window.location.href;
9+
const isBrowser = useIsBrowser();
10+
const [currentUrl, setCurrentUrl] = useState(
11+
"https://www.revenuecat.com/docs",
12+
);
13+
14+
useEffect(() => {
15+
if (isBrowser) {
16+
setCurrentUrl(window.location.href);
1017
}
11-
return "";
12-
};
18+
}, [isBrowser]);
1319

1420
const createAIProviderUrl = (baseUrl: string, prompt: string) => {
15-
const currentUrl = getCurrentUrl();
16-
const message = `Use ${currentUrl} as context.\n\n`;
21+
const message = currentUrl ? `Use ${currentUrl} as context.\n\n` : "";
1722
return `${baseUrl}${encodeURIComponent(message + prompt)}`;
1823
};
1924

0 commit comments

Comments
 (0)