Skip to content

Commit c6191db

Browse files
committed
Fix norwegian links in search
1 parent 1a0168e commit c6191db

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

web/sections/searchBlocks/UniversalHit.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ const buildDisplayURL = (slug: string, locale: string | undefined): string => {
3333
: `${host.url}${slug}`
3434
}
3535

36+
const buildURL = (slug: string, locale: string | undefined): string => {
37+
const startsWithLocale =
38+
slug.startsWith(`${locale}/`) || slug.startsWith(`/${locale}/`)
39+
return locale && locale !== defaultLanguage?.iso && !startsWithLocale
40+
? `/${getLocaleFromIso(locale)}/${slug.replace(/^\//, '')}`
41+
: `${slug}`
42+
}
43+
3644
const UniversalHit: React.FC<HitProps> = ({ hit }) => {
3745
const {
3846
slug = '',
@@ -62,7 +70,7 @@ const UniversalHit: React.FC<HitProps> = ({ hit }) => {
6270

6371
return (
6472
<article className='border-white-100/20 border-b pt-6 pb-8'>
65-
<BaseLink href={slug} className='group'>
73+
<BaseLink href={buildURL(slug, locale)} className='group'>
6674
{formattedDate && type !== 'magazine' && (
6775
<FormattedDateTime
6876
uppercase

0 commit comments

Comments
 (0)