Skip to content

Commit fbc26bf

Browse files
committed
Made it work on Seven as well
1 parent 59d7889 commit fbc26bf

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

packages/fortytwo/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"release-it": "^17.1.1"
4242
},
4343
"dependencies": {
44-
"query-string": "^9.3.1",
45-
"react-router-dom": "5.2.0"
44+
"query-string": "^9.3.1"
4645
}
4746
}
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import { Redirect } from 'react-router-dom';
1+
import { useEffect } from 'react';
22
import qs from 'query-string';
3-
import { isCmsUi } from '@plone/volto/helpers/Url/Url';
43
import config from '@plone/registry';
54

5+
export const isNonContentRoute = (currentPathname: string) => {
6+
const { settings } = config;
7+
const fullPath = currentPathname.replace(/\?.*$/, '');
8+
return settings.nonContentRoutes.reduce(
9+
(acc, route) => acc || new RegExp(route).test(fullPath),
10+
false,
11+
);
12+
};
13+
614
export default function ViewRedirector({
715
pathname,
816
location,
@@ -12,13 +20,11 @@ export default function ViewRedirector({
1220
}) {
1321
const search = qs.parse(location.search);
1422

15-
if (!isCmsUi(pathname) && !search.noRedirect) {
16-
if (__SERVER__) {
17-
return <Redirect to={config.settings.fortytwo.razzleSevenUrl} />;
18-
} else {
23+
useEffect(() => {
24+
if (!isNonContentRoute(pathname) && !search.noRedirect) {
1925
window.location.href = config.settings.fortytwo.razzleSevenUrl;
2026
}
21-
}
27+
}, [pathname, search.noRedirect]);
2228

2329
return null;
2430
}

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)