Skip to content

Commit 492814d

Browse files
authored
Merge pull request #784 from rvsia/fixAlgolia
Revert "Redirect on examples when no mapper"
2 parents fac2106 + 3d59902 commit 492814d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/react-renderer-demo/src/components/component-example.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,9 @@ const mapperTab = {
157157

158158
const ComponentExample = ({ variants, schema, activeMapper, component }) => {
159159
const activeTab = mapperTab[activeMapper];
160-
const { pathname, push, query, asPath } = useRouter();
160+
const { pathname, push } = useRouter();
161161
const classes = useStyles();
162162
useEffect(() => {
163-
if (!query?.mapper) {
164-
const [path, hash] = asPath.split('#');
165-
push(`${path}?mapper=mui${hash ? `#${hash}` : ''}`);
166-
}
167-
168163
sdk.embedProject(
169164
'code-target',
170165
{

packages/react-renderer-demo/src/pages/404.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ const Custom404 = () => {
6464

6565
if (asPath.includes('/component-example/')) {
6666
setLoading(true);
67-
push(asPath.replace('/component-example/', '/mappers/'));
67+
68+
let newPath = asPath.replace('/component-example/', '/mappers/');
69+
70+
if (!newPath.match(/\?mapper=/) && !newPath.match(/#/)) {
71+
newPath = `${newPath}?mapper=mui`;
72+
} else if (!newPath.match(/\?mapper=/)) {
73+
newPath = newPath.replace(/#/, '?mapper=mui#');
74+
}
75+
76+
push(newPath);
6877
} else if (asPath.startsWith('/renderer/condition#') && conditionHashMapper[hash]) {
6978
setLoading(true);
7079
push(`/schema/${conditionHashMapper[hash]}`);

0 commit comments

Comments
 (0)