Skip to content

Commit a35d541

Browse files
authored
fix: unmount kapa widget from default error page (#2598)
1 parent aa45903 commit a35d541

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/theme/KapaWidget.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
import React, { useState } from "react"
1+
import React, { useEffect, useState } from "react"
2+
import { useLocation } from "@docusaurus/router"
3+
4+
const EXCLUDED_PATHS = ["/docs/kratos/fallback/error"]
25

36
export default function KapaWidget() {
47
const [isScriptLoaded, setIsScriptLoaded] = useState(false)
8+
const { pathname } = useLocation()
9+
const isExcluded = EXCLUDED_PATHS.includes(pathname)
10+
11+
useEffect(() => {
12+
if (isExcluded && typeof window !== "undefined" && (window as any).Kapa) {
13+
;(window as any).Kapa("unmount")
14+
}
15+
}, [isExcluded])
16+
17+
if (isExcluded) {
18+
return null
19+
}
520

621
const loadKapaWidget = () => {
722
if (isScriptLoaded) {

0 commit comments

Comments
 (0)