docs: show badge for community integrations (#13691)
This commit is contained in:
1 parent
62d340b897
commit
54cf8811af
1 file changed
+57
-43
@@ -12,7 +12,7 @@ import {
|
|||||||
} from "react-instantsearch"
|
} from "react-instantsearch"
|
||||||
import { SearchNoResult } from "../NoResults"
|
import { SearchNoResult } from "../NoResults"
|
||||||
import { useSearch } from "@/providers"
|
import { useSearch } from "@/providers"
|
||||||
import { Link, SearchHitGroupName } from "@/components"
|
import { Badge, Link, SearchHitGroupName } from "@/components"
|
||||||
|
|
||||||
export type Hierarchy = "lvl0" | "lvl1" | "lvl2" | "lvl3" | "lvl4" | "lvl5"
|
export type Hierarchy = "lvl0" | "lvl1" | "lvl2" | "lvl3" | "lvl4" | "lvl5"
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ export type HitType = {
|
|||||||
__queryID?: string
|
__queryID?: string
|
||||||
objectID: string
|
objectID: string
|
||||||
description?: string
|
description?: string
|
||||||
|
integration_vendor?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GroupedHitType = {
|
export type GroupedHitType = {
|
||||||
@@ -157,14 +158,14 @@ export const SearchHits = ({
|
|||||||
.join(" › ")
|
.join(" › ")
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
key={index}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"gap-docs_0.25 relative flex flex-1 flex-col p-docs_0.5",
|
"p-docs_0.5",
|
||||||
"overflow-x-hidden text-ellipsis whitespace-nowrap break-words",
|
|
||||||
"hover:bg-medusa-bg-base-hover",
|
"hover:bg-medusa-bg-base-hover",
|
||||||
"focus:bg-medusa-bg-base-hover",
|
"focus:bg-medusa-bg-base-hover",
|
||||||
"focus:outline-none"
|
"focus:outline-none",
|
||||||
|
"flex justify-between items-center"
|
||||||
)}
|
)}
|
||||||
key={index}
|
|
||||||
tabIndex={index}
|
tabIndex={index}
|
||||||
data-hit
|
data-hit
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -174,49 +175,62 @@ export const SearchHits = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"text-compact-small-plus text-medusa-fg-base",
|
"gap-docs_0.25 relative flex flex-1 flex-col",
|
||||||
"max-w-full"
|
"overflow-x-hidden text-ellipsis whitespace-nowrap break-words"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
|
<span
|
||||||
<Snippet
|
className={clsx(
|
||||||
attribute={getHierarchySnippetAttribute(item)}
|
"text-compact-small-plus text-medusa-fg-base",
|
||||||
hit={item}
|
"max-w-full"
|
||||||
/>
|
)}
|
||||||
</span>
|
>
|
||||||
<span className="text-compact-small text-medusa-fg-subtle text-ellipsis overflow-hidden">
|
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
|
||||||
{item.type === "content" && (
|
<Snippet
|
||||||
<>
|
attribute={getHierarchySnippetAttribute(item)}
|
||||||
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
|
hit={item}
|
||||||
<Snippet attribute={"content"} hit={item} />
|
/>
|
||||||
</>
|
</span>
|
||||||
)}
|
<span className="text-compact-small text-medusa-fg-subtle text-ellipsis overflow-hidden">
|
||||||
{item.type !== "content" && item.description}
|
{item.type === "content" && (
|
||||||
</span>
|
<>
|
||||||
|
{/* @ts-expect-error React v19 doesn't see this type as a React element */}
|
||||||
|
<Snippet attribute={"content"} hit={item} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{item.type !== "content" && item.description}
|
||||||
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"text-ellipsis overflow-hidden",
|
"text-ellipsis overflow-hidden",
|
||||||
"text-medusa-fg-muted items-center text-compact-x-small"
|
"text-medusa-fg-muted items-center text-compact-x-small"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{hierarchies}
|
||||||
|
</span>
|
||||||
|
<Link
|
||||||
|
href={item.url}
|
||||||
|
className="absolute top-0 left-0 h-full w-full"
|
||||||
|
target="_self"
|
||||||
|
onClick={(e) => {
|
||||||
|
sendEvent("click", item, "Search Result Clicked")
|
||||||
|
if (checkIfInternal(item.url)) {
|
||||||
|
e.preventDefault()
|
||||||
|
window.location.href = item.url
|
||||||
|
setIsOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{!!item.integration_vendor &&
|
||||||
|
item.integration_vendor !== "Medusa" && (
|
||||||
|
<Badge variant="blue" badgeType="shaded">
|
||||||
|
Community
|
||||||
|
</Badge>
|
||||||
)}
|
)}
|
||||||
>
|
|
||||||
{hierarchies}
|
|
||||||
</span>
|
|
||||||
<Link
|
|
||||||
href={item.url}
|
|
||||||
className="absolute top-0 left-0 h-full w-full"
|
|
||||||
target="_self"
|
|
||||||
onClick={(e) => {
|
|
||||||
sendEvent("click", item, "Search Result Clicked")
|
|
||||||
if (checkIfInternal(item.url)) {
|
|
||||||
e.preventDefault()
|
|
||||||
window.location.href = item.url
|
|
||||||
setIsOpen(false)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in new issue
Block a user