Skip to content

Commit

Permalink
🔍 Allow search results to lead offsite
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Jan 5, 2021
1 parent 4a3dacf commit 98b8253
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Heading, SearchField, Text } from '@adobe/react-spectrum'
import { Menu } from '../Menu'
import { Popover } from '../Popover'
import { navigate } from 'gatsby'
import { isExternal } from '../utils'

const Search = ({
sections,
Expand Down Expand Up @@ -80,8 +81,12 @@ const Search = ({

const loadResult = (item) => {
setIsOpen(false)
const path = item.path.startsWith('/') ? item.path : `/${item.path}`
navigate(path)
if (isExternal(item.path)) {
document.location.href = item.path
} else {
const path = item.path.startsWith('/') ? item.path : `/${item.path}`
navigate(path)
}
}

return (
Expand Down

0 comments on commit 98b8253

Please sign in to comment.