2020-08-27 13:47:17 +00:00
|
|
|
import Search from '@hashicorp/react-search'
|
|
|
|
|
|
|
|
export default function SearchBar() {
|
|
|
|
return (
|
|
|
|
<Search
|
|
|
|
renderHitContent={({ hit, Highlight }) => (
|
|
|
|
<>
|
|
|
|
<span className="name">
|
|
|
|
<Highlight attribute="page_title" hit={hit} tagName="span" />
|
|
|
|
</span>
|
|
|
|
<span className="description">
|
|
|
|
<Highlight attribute="description" hit={hit} tagName="span" />
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2020-09-02 21:21:10 +00:00
|
|
|
resolveHitLink={(hit) => ({
|
|
|
|
href: {
|
|
|
|
pathname: `/${transformIdtoUrl(hit.objectID)}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-08-27 13:47:17 +00:00
|
|
|
placeholder="Search Nomad documentation"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-09-02 21:21:10 +00:00
|
|
|
|
|
|
|
function transformIdtoUrl(id) {
|
|
|
|
return id.replace(/\/index$/, '')
|
|
|
|
}
|