Merged in fix/current-languageswitcher-nofollow (pull request #2064)

fix: add no-follow to links in language switcher

* fix: add no-follow to links in language switcher


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-05-13 07:47:47 +00:00
committed by Linus Flood
parent 5a351991e1
commit 40570c356a
2 changed files with 17 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
import { useCallback, useEffect, useRef, useState } from "react"
import { type Lang, languages } from "@/constants/languages"
import { env } from "@/env/client"
import Link from "@/components/TempDesignSystem/Link"
import useLang from "@/hooks/useLang"
@@ -81,11 +82,19 @@ export default function Desktop({ urls }: LanguageSwitcherProps) {
className={`${styles.li} ${currentLanguage === key ? styles.active : ""}`}
>
{urls[key as Lang]?.isExternal ? (
<Link className={styles.link} href={url}>
<Link
className={styles.link}
href={url}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
{languages[key as Lang]}
</Link>
) : (
<a className={styles.link} href={url}>
<a
className={styles.link}
href={url}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
{languages[key as Lang]}
</a>
)}

View File

@@ -4,6 +4,7 @@
import { useState } from "react"
import { type Lang, languages } from "@/constants/languages"
import { env } from "@/env/client"
import useLang from "@/hooks/useLang"
@@ -44,7 +45,11 @@ export default function Mobile({ urls }: LanguageSwitcherProps) {
if (url) {
return (
<li key={key} className={styles.li}>
<a href={url} className={styles.link}>
<a
href={url}
className={styles.link}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
{languages[key as Lang]}
</a>
</li>