Skip to content

Commit

Permalink
improve Links to use locale
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Feb 6, 2025
1 parent d4b1007 commit b6e98e1
Show file tree
Hide file tree
Showing 72 changed files with 357 additions and 381 deletions.
2 changes: 1 addition & 1 deletion src/components/Announcements/TabContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"

const TabContent = ({ posts }) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ exports[`Announcements component > Announcements renders correctly 1`] = `
class="overflow-auto h-[88%] scroll-sidebar"
>
<article>
<a>
<a
href="/enundefined"
>
<div
class="text-[#c4bfce"
>
Expand All @@ -101,7 +103,9 @@ exports[`Announcements component > Announcements renders correctly 1`] = `
<span
class="h-[1px] w-full bg-[#3E3355] inline-block my-4"
/>
<a>
<a
href="/enundefined"
>
<div
class="text-[#c4bfce"
>
Expand All @@ -126,7 +130,9 @@ exports[`Announcements component > Announcements renders correctly 1`] = `
<span
class="h-[1px] w-full bg-[#3E3355] inline-block my-4"
/>
<a>
<a
href="/enundefined"
>
<div
class="text-[#c4bfce"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exports[`BlogAuthor component > should render correctly 1`] = `
<p>
Posted by
<a
href="/news/author/pmc"
href="/en/news/author/pmc"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/BlogAuthor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import { FaGithub, FaLinkedin } from "react-icons/fa"
import { FaXTwitter } from "react-icons/fa6"
import { Link } from "gatsby"
import { Link } from "../Link"

import ProfilePic from "../ProfilePic"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ exports[`CommonButton component > should render correctly 1`] = `
test
</p>
</div>
<a>
<a
href="/enundefined"
>
<button
class="bg-transparent border-2 border-pink-500/0 text-white text-base leading-6 font-normal w-[180px] h-[48px] rounded-[80px] gradient-border "
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Common/CommonCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../../Link"

const CommonCard = ({ data }) => {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Common/CommonDownloader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react"
import { Link, Trans } from "gatsby-plugin-react-i18next"
import { Trans } from "gatsby-plugin-react-i18next"
import { BsCopy, BsDownload } from "react-icons/bs"
import { MdVerifiedUser } from "react-icons/md"
import { Link } from "../../Link"

const CommonDownloader = ({ openModalWithChecksum, obj }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Events/EventCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../../Link"

const EventCard = ({ post }) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer/MobileFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"
import { Link, Trans } from "gatsby-plugin-react-i18next"
import { Trans } from "gatsby-plugin-react-i18next"
import { Disclosure } from "@headlessui/react"

import { CiCirclePlus, CiCircleMinus } from "react-icons/ci"
import { Link } from "../Link"

// Custom Disclosure component
const CustomDisclosure = ({ title, links }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ exports[`Footer component > renders correctly 1`] = `
<li>
<a
class="text-white text-base font-normal leading-6 transition hover:opacity-75 dark:text-gray-200"
href="/docs"
href="/en/docs"
>
Text
</a>
</li>
<li>
<a
class="text-white text-base font-normal leading-6 transition hover:opacity-75 dark:text-gray-200"
href="/contributing"
href="/en/contributing"
>
Text
</a>
Expand Down Expand Up @@ -551,7 +551,7 @@ exports[`Footer component > renders correctly 1`] = `
<li>
<a
class="leading-6 transition hover:opacity-75 dark:text-gray-200"
href="/slack"
href="/en/slack"
rel="noreferrer"
target="_blank"
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useState } from "react"
import { Link, Trans, useTranslation } from "gatsby-plugin-react-i18next"
import { Trans, useTranslation } from "gatsby-plugin-react-i18next"
import { SmallLogoIcon } from "../Common/Icon"
import MobileFooter from "./MobileFooter"
import IconSocial from "../IconSocial"
import LeavingSiteDisclaimerModal from '../LeavingSiteDisclaimerModal';
import { Link } from "../Link"

interface FooterData {
title: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/IconSocial/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"
import { FaGithub, FaLinkedin, FaSlack, FaYoutube } from "react-icons/fa"
import { FaXTwitter, FaBluesky, FaMastodon } from "react-icons/fa6"

Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageText/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"

const ImageText = ({ title, description, link, linkText }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/InstallTabs/LinuxPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { graphql, useStaticQuery } from "gatsby"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../../Link"
import ShellBox from "../../ShellBox"
import "../InstallTabs.scss"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ exports[`Tests for InstallTabs component > renders correctly for Linux 1`] = `
</pre>
<a
class="install__docs-button"
href="/installation/linux"
href="/en/installation/linux"
>
Read documentation
</a>
Expand Down Expand Up @@ -588,7 +588,7 @@ exports[`Tests for InstallTabs component > renders correctly for Unix 1`] = `
</pre>
<a
class="install__docs-button"
href="/installation/linux"
href="/en/installation/linux"
>
Read documentation
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports[`Tests for LinuxPanel component > renders correctly 1`] = `
</pre>
<a
class="install__docs-button"
href="/installation/linux"
href="/en/installation/linux"
>
Read documentation
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LatestNews/LatestNewsSlider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef, useEffect } from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"
import { Swiper, SwiperSlide, SwiperRef } from "swiper/react"
import SwiperCore from "swiper"
import { Navigation } from "swiper/modules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports[`Latest News component > renders correctly 1`] = `
Eclipse Temurin offers high-performance, cross-platform, open-source Java runtime binaries that are enterprise-ready and Java SE TCK-tested for general use in the Java ecosystem.
</h3>
<a
href="/news"
href="/en/news"
>
<button
class="rounded-2xl bg-transparent gradient-border border-2 border-pink-500/0 text-white text-base leading-6 font-bold w-[154px] h-[48px] block "
Expand Down Expand Up @@ -83,6 +83,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -133,6 +134,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -187,6 +189,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -237,6 +240,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -298,6 +302,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -348,6 +353,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -398,6 +404,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down Expand Up @@ -448,6 +455,7 @@ exports[`Latest News component > renders correctly 1`] = `
</span>
<a
class="py-3 text-base underline font-bold leading-6 text-white mt-2 block border-white w-fit"
href="/enundefined"
>
Read More
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LatestNews/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"
import LatestNewsSlider from "./LatestNewsSlider"
import { RedIcon } from "../Common/Icon"

Expand Down
24 changes: 24 additions & 0 deletions src/components/Link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { Link as GatsbyLink, GatsbyLinkProps } from "gatsby";
import { useI18next } from "gatsby-plugin-react-i18next";

type I18nLinkProps = GatsbyLinkProps<any> & {
language?: string;
};

export const Link: React.FC<I18nLinkProps> = ({ language, to, ...rest }) => {
const {
language: currentLanguage,
defaultLanguage,
generateDefaultLanguagePage,
} = useI18next();

const urlLanguage = language || currentLanguage;
const getLanguagePath = (lang: string) =>
generateDefaultLanguagePage || lang !== defaultLanguage ? `/${lang}` : "";

const localizedTo = `${getLanguagePath(urlLanguage)}${to}`;

// @ts-ignore
return <GatsbyLink {...rest} to={localizedTo} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`LinkText component > external URL renders correctly 1`] = `
exports[`LinkText component > internal link renders correctly 1`] = `
<div>
<a
href="/page1"
href="/en/page1"
>
Page 1
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LinkText/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../Link"
import React from "react"

type LinkTextProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Marketplace/AllReleaseCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import { Link } from "../../Link"

import { capitalize } from "../../../util/capitalize"
import { getImageForDistribution } from "../../../hooks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`NavBar component > navbar renders correctly 1`] = `
class="flex items-center gap-5 justify-between py-6"
>
<a
href="/"
href="/en/"
placeholder="homepage"
>
<img
Expand Down Expand Up @@ -58,13 +58,13 @@ exports[`NavBar component > navbar renders correctly 1`] = `
</div>
<a
class="text-sm font-semibold leading-6 text-white-900"
href="/temurin/releases"
href="/en/temurin/releases"
>
Latest Releases
</a>
<a
class="text-sm font-semibold leading-6 text-white-900"
href="/marketplace"
href="/en/marketplace"
>
Marketplace
</a>
Expand Down
Loading

0 comments on commit b6e98e1

Please sign in to comment.