From 0fc1dbc6c559dad44e7d5f852c8e326e94638ed5 Mon Sep 17 00:00:00 2001 From: Katja Lutz Date: Mon, 27 Jun 2022 21:53:12 +0200 Subject: [PATCH] feat: add externalLink and getDomain utilities --- src/util.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util.tsx b/src/util.tsx index 979064c..5e92b79 100644 --- a/src/util.tsx +++ b/src/util.tsx @@ -65,7 +65,10 @@ export const shuffle = (list: any[]) => { return list; }; -export const getHost = () => "https://rappli.ch"; +export const getDomain = () => + import.meta.env.SSR ? process.env.DOMAIN || "localhost" : location.hostname; + +export const getHost = () => `https://${getDomain()}`; export const onClickFocus: JSX.EventHandlerUnion< HTMLAnchorElement, @@ -83,3 +86,5 @@ export const onClickFocus: JSX.EventHandlerUnion< targetEl.focus(); }; + +export const externalLink = { target: "_blank", rel: "noopener" };