Skip to content

Commit

Permalink
Add zoom for redirects routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia-Lavrova committed Jan 28, 2021
1 parent 6295f95 commit d96755a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ app.use('/_api/heritage_info', createProxyMiddleware({
changeOrigin: true,
}));

app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

Object.keys(shortRouteToPages).map((route) => {
app.get(route, function(req, res) {
res.redirect(shortRouteToPages[route]);
});
});

app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(9000);
34 changes: 21 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import Map from 'components/Map';
import DefaultMap from 'components/DefaultMap';
import Sidebar from 'components/Sidebar';
import MonumentPage from 'components/MonumentPage';
import RedirectWithZoom from 'components/RedirectWithZoom';

import { DEFAULT_ZOOM } from 'constants/map';

import './App.scss';

Expand All @@ -18,58 +21,63 @@ const App = () => (
<main>
<Switch>
<Route path="/moscow">
<Redirect to="/lat/55.744654/lon/37.624991" />
<Redirect to={`/lat/55.744654/lon/37.624991/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/nizhny-novgorod">
<Redirect to="/lat/56.301011/lon/43.995229" />
<Redirect to={`/lat/56.301011/lon/43.995229/zoom/${DEFAULT_ZOOM}`} />
</Route>


<Route path="/arzamas">
<Redirect to="/lat/55.386373/lon/43.817099" />
<Redirect to={`/lat/55.386373/lon/43.817099/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/balakhna">
<Redirect to="/lat/56.492938/lon/43.611212" />
<Redirect to={`/lat/56.492938/lon/43.611212/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/bogorodsk">
<Redirect to="/lat/56.101523/lon/43.516550" />
<Redirect to={`/lat/56.101523/lon/43.516550/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/bolshoe-murashkino">
<Redirect to="/lat/55.781787/lon/44.774134" />
<Redirect to={`/lat/55.781787/lon/44.774134/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/vyksa">
<Redirect to="/lat/55.318686/lon/42.186628" />
<Redirect to={`/lat/55.318686/lon/42.186628/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/gorbatov">
<Redirect to="/lat/56.131309/lon/43.058318" />
<Redirect to={`/lat/56.131309/lon/43.058318/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/lyskovo">
<Redirect to="/lat/56.037971/lon/45.0478428" />
<Redirect to={`/lat/56.037971/lon/45.0478428/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/gorodets">
<Redirect to="/lat/56.644823/lon/43.469353" />
<Redirect to={`/lat/56.644823/lon/43.469353/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/dzerzhinsk">
<Redirect to="/lat/56.238716/lon/43.461149" />
<Redirect to={`/lat/56.238716/lon/43.461149/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/pavlovo">
<Redirect to="/lat/55.963602/lon/43.070018" />
<Redirect to={`/lat/55.963602/lon/43.070018/zoom/${DEFAULT_ZOOM}`} />
</Route>

<Route path="/lat/:lat/lon/:lon/:id?">
<Route path="/lat/:lat/lon/:lon/zoom/:zoom/:id?">
<Map />
<Sidebar />
</Route>

<Route path="/lat/:lat/lon/:lon/:id?">
<RedirectWithZoom />
</Route>

<Route path="/:id">
<MonumentPage />
</Route>
Expand Down

0 comments on commit d96755a

Please sign in to comment.