Skip to content

Commit

Permalink
fix: translation for speaker preview x2 (speaker card links)
Browse files Browse the repository at this point in the history
  • Loading branch information
domysh committed Sep 29, 2024
1 parent d42b4f5 commit 5073bac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Home/RandomSpeakerList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { Speaker } from "../../data/types/sessionize";
import { getLangFromUrl, useTranslatedPath, useTranslations } from "../../i18n/utils";

const SpeakerPreviewElement = ({ speaker }: { speaker: Speaker }) => (
<a
const SpeakerPreviewElement = ({ speaker }: { speaker: Speaker }) => {
const lang = getLangFromUrl(new URL(location.href));
const getPath = useTranslatedPath(lang);
return <a
key={speaker.id}
href={`/speakers/${speaker.slug}`}
href={getPath(`/speakers/${speaker.slug}`)}
className="speaker-card"
>
<figure>
Expand All @@ -18,7 +21,7 @@ const SpeakerPreviewElement = ({ speaker }: { speaker: Speaker }) => (
<p className="max-h-12 text-ellipsis overflow-hidden">{speaker.tagLine}</p>
</div>
</a>
)
}

export const RandomSpeakerList = ({ speakers }:{ speakers:Speaker[] }) => {
return <>{speakers.sort(() => Math.random() - 0.5).slice(0, 4).map((s) => (
Expand Down

0 comments on commit 5073bac

Please sign in to comment.