fix window not defined issue

pull/21606/head
bracesproul 2 weeks ago
parent 1d1d5865e8
commit 837ae10711

@ -112,6 +112,7 @@ export default function Feedback() {
const { setCookie, checkCookie } = useCookie();
const [feedbackSent, setFeedbackSent] = useState(false);
const { siteConfig } = useDocusaurusContext();
const [pathname, setPathname] = useState("");
/** @param {"good" | "bad"} feedback */
const handleFeedback = async (feedback) => {
@ -167,6 +168,7 @@ export default function Feedback() {
// (cookies exp in 24hrs)
const cookieName = `${FEEDBACK_COOKIE_PREFIX}_${window.location.pathname}`;
setFeedbackSent(checkCookie(cookieName));
setPathname(window.location.pathname);
}
}, []);
@ -192,7 +194,9 @@ export default function Feedback() {
onMouseUp: (e) => (e.currentTarget.style.backgroundColor = "#f0f0f0"),
};
const newGithubIssueURL = `https://github.com/langchain-ai/langchain/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CIssue+related+to+${window.location.pathname}%3E`;
const newGithubIssueURL = pathname
? `https://github.com/langchain-ai/langchain/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CIssue+related+to+${pathname}%3E`
: "https://github.com/langchain-ai/langchain/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E";
return (
<div style={{ display: "flex", flexDirection: "column" }}>

Loading…
Cancel
Save