diff --git a/src/documentation/ideas/IdeasDocumentation.tsx b/src/documentation/ideas/IdeasDocumentation.tsx index 9288a9559..915a6ecfc 100644 --- a/src/documentation/ideas/IdeasDocumentation.tsx +++ b/src/documentation/ideas/IdeasDocumentation.tsx @@ -22,6 +22,8 @@ import { isV2Only } from "../common/model"; import IdeaCard from "./IdeaCard"; import { Idea } from "./model"; import OfflineImageFallback from "../OfflineImageFallback"; +import { microbitOrgMiciProjectsUrl } from "../../external-links"; +import { useSettings } from "../../settings/settings"; interface IdeasDocumentationProps { ideas: Idea[]; @@ -64,6 +66,7 @@ const ActiveLevel = ({ }: ActiveLevelProps) => { const activeIdea = ideas.find((idea) => idea.slug.current === ideaId); const intl = useIntl(); + const [{ languageId }] = useSettings(); const headingString = intl.formatMessage({ id: "ideas-tab" }); const ref = useRef(null); const contentRect = useResizeObserverContentRect(ref); @@ -156,7 +159,7 @@ const ActiveLevel = ({ link: (chunks: ReactNode) => ( diff --git a/src/external-links.ts b/src/external-links.ts new file mode 100644 index 000000000..f5e7dcfe2 --- /dev/null +++ b/src/external-links.ts @@ -0,0 +1,30 @@ +const microbitOrgSupportedLangs = [ + "ar", + "ca", + "cy", + "es-es", + "fr", + "hr", + "ja", + "ko", + "nl", + "pl", + "pt-br", + "pt-pt", + "sr", + "zh-cn", + "zh-tw", +]; + +const langPath = (languageId: string) => { + const lang = languageId.toLowerCase(); + return microbitOrgSupportedLangs.includes(lang) ? `${lang}/` : ""; +}; + +export const microbitOrgUrl = (languageId: string) => + `https://microbit.org/${langPath(languageId)}`; + +export const microbitOrgMiciProjectsUrl = (languageId: string) => + `https://microbit.org/${langPath( + languageId + )}projects/make-it-code-it/?filters=python`; diff --git a/src/workbench/SideBarHeader.tsx b/src/workbench/SideBarHeader.tsx index 511059111..772890e79 100644 --- a/src/workbench/SideBarHeader.tsx +++ b/src/workbench/SideBarHeader.tsx @@ -30,6 +30,7 @@ import { topBarHeight } from "../deployment/misc"; import { supportedSearchLanguages } from "../documentation/search/search.worker"; import { useSearch } from "../documentation/search/search-hooks"; import SearchDialog from "../documentation/search/SearchDialog"; +import { microbitOrgUrl } from "../external-links"; import { useLogging } from "../logging/logging-hooks"; import { RouterState, useRouterState } from "../router-hooks"; import { useSettings } from "../settings/settings"; @@ -186,7 +187,7 @@ const SideBarHeader = ({ >