Skip to content

Commit 0069a5c

Browse files
committed
#3476 Fix links in search hits
1 parent 201c48b commit 0069a5c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

web/sections/searchBlocks/UniversalHit.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { defaultLanguage } from '@/languageConfig'
77
import { host } from '@/lib/config'
88
import { Highlight } from './Highlight'
99
import DisplayLink from './hit/DisplayLink'
10+
import { getLocaleFromIso, getNameFromLocale } from '@/sanity/helpers/localization'
1011

1112
export type HitData = {
1213
slug?: string
@@ -26,9 +27,8 @@ export type HitProps = { hit: UniversalHitType }
2627
const buildDisplayURL = (slug: string, locale: string | undefined): string => {
2728
const startsWithLocale =
2829
slug.startsWith(`${locale}/`) || slug.startsWith(`/${locale}/`)
29-
30-
return locale && locale !== defaultLanguage?.locale && !startsWithLocale
31-
? `${host.url}/${locale}/${slug.replace(/^\//, '')}`
30+
return locale && locale !== defaultLanguage?.iso && !startsWithLocale
31+
? `${host.url}/${getLocaleFromIso(locale)}/${slug.replace(/^\//, '')}`
3232
: `${host.url}${slug}`
3333
}
3434

0 commit comments

Comments
 (0)