diff --git a/src/pages/index/+Page.tsx b/src/pages/index/+Page.tsx index c47160c..d202b8a 100644 --- a/src/pages/index/+Page.tsx +++ b/src/pages/index/+Page.tsx @@ -1,10 +1,12 @@ -import './index.scss' +import "./index.scss"; import HomeHero from "#root/pages/index/components/HomeHero"; const IndexPage = () => { - return <> - - ; + return ( + <> + + + ); }; export default IndexPage; diff --git a/src/shared/components/Link.tsx b/src/shared/components/Link.tsx new file mode 100644 index 0000000..6c515ee --- /dev/null +++ b/src/shared/components/Link.tsx @@ -0,0 +1,18 @@ +import { usePageContext } from "@techmely/vike-react/usePageContext"; +import type { AnchorHTMLAttributes, DetailedHTMLProps, FC } from "react"; +import { type Locale, baseLocale } from "#root/locales/locales.utils"; + +type Props = DetailedHTMLProps, HTMLAnchorElement> & { + locale?: Locale; +}; + +const Link: FC = ({ href, locale, ...props }) => { + const pageContext = usePageContext(); + locale = locale || (pageContext.metadata?.locale as Locale); + if (locale !== baseLocale) { + href = `/${locale}${href}`; + } + return ; +}; + +export default Link; diff --git a/src/shared/libs/url/tenant.ts b/src/shared/libs/url/tenant.ts new file mode 100644 index 0000000..838a090 --- /dev/null +++ b/src/shared/libs/url/tenant.ts @@ -0,0 +1,6 @@ +export function composeTenantUrl(tenant: string, protocol: string, host: string) { + if (host.startsWith(tenant)) { + return `${protocol}//${host}`; + } + return `${protocol}//${tenant ? `${tenant}.` : ""}${host}`; +}