mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 11:05:31 +08:00
fix(kilo-docs): keep docsearch links on previews
This commit is contained in:
@@ -215,6 +215,15 @@ interface TopNavProps {
|
||||
showMobileMenuButton?: boolean
|
||||
}
|
||||
|
||||
function preview(url: string) {
|
||||
if (typeof window === "undefined" || !URL.canParse(url)) return url
|
||||
|
||||
const value = new URL(url)
|
||||
if (value.hostname !== "kilo.ai" || !value.pathname.startsWith("/docs")) return url
|
||||
|
||||
return `${window.location.origin}${value.pathname}${value.search}${value.hash}`
|
||||
}
|
||||
|
||||
export function TopNav({ onMobileMenuToggle, isMobileMenuOpen = false, showMobileMenuButton = true }: TopNavProps) {
|
||||
const router = useRouter()
|
||||
const [openDropdown, setOpenDropdown] = useState<string | null>(null)
|
||||
@@ -250,6 +259,12 @@ export function TopNav({ onMobileMenuToggle, isMobileMenuOpen = false, showMobil
|
||||
indexName: process.env.NEXT_PUBLIC_ALGOLIA_INDEX_NAME || "docsearch",
|
||||
apiKey: process.env.NEXT_PUBLIC_ALGOLIA_API_KEY || "24b09689d5b4223813d9b8e48563c8f6",
|
||||
askAi: process.env.NEXT_PUBLIC_ALGOLIA_ASSISTANT_ID || "askAIDemo",
|
||||
transformItems(items) {
|
||||
return items.map((item) => ({
|
||||
...item,
|
||||
url: preview(item.url),
|
||||
}))
|
||||
},
|
||||
})
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user