From 41b3d409fde0e1bb07cff31a30387437e1e1fce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corne=CC=81=20Dorrestijn?= Date: Thu, 29 Dec 2022 17:42:54 +0100 Subject: [PATCH] Allow configuration from root URL path --- app/soapbox/features/public-layout/index.tsx | 11 +++++++++-- app/soapbox/normalizers/soapbox/soapbox-config.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/public-layout/index.tsx b/app/soapbox/features/public-layout/index.tsx index 0fdc8b946..3671b5ae8 100644 --- a/app/soapbox/features/public-layout/index.tsx +++ b/app/soapbox/features/public-layout/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Switch, Route, Redirect } from 'react-router-dom'; import LandingGradient from 'soapbox/components/landing-gradient'; -import { useAppSelector } from 'soapbox/hooks'; +import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks'; import { isStandalone } from 'soapbox/utils/state'; import AboutPage from '../about'; @@ -13,6 +13,9 @@ import Header from './components/header'; const PublicLayout = () => { const standalone = useAppSelector((state) => isStandalone(state)); + const soapboxConfig = useSoapboxConfig(); + + const shouldRedirectFromRoot = soapboxConfig.redirectRootNoLogin && !soapboxConfig.redirectRootNoLogin.match(/^\/?$/); if (standalone) { return ; @@ -28,7 +31,11 @@ const PublicLayout = () => {
- + {shouldRedirectFromRoot ? ( + + ) : ( + + )}
diff --git a/app/soapbox/normalizers/soapbox/soapbox-config.ts b/app/soapbox/normalizers/soapbox/soapbox-config.ts index b221afabe..06848cc7a 100644 --- a/app/soapbox/normalizers/soapbox/soapbox-config.ts +++ b/app/soapbox/normalizers/soapbox/soapbox-config.ts @@ -115,6 +115,7 @@ export const SoapboxConfigRecord = ImmutableRecord({ feedInjection: true, tileServer: '', tileServerAttribution: '', + redirectRootNoLogin: '/', }, 'SoapboxConfig'); type SoapboxConfigMap = ImmutableMap;