Advertisement
Guest User

Untitled

a guest
May 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import Home from "../pages/Home/Home";
  2. import RSVP from "../pages/RSVP/RSVP";
  3. import WeddingDay from "../pages/WeddingDay/WeddingDay";
  4. import AfterParty from "../pages/AfterParty/AfterParty";
  5.  
  6. const HOME = {
  7. path: "/",
  8. title: "Home",
  9. component: Home
  10. };
  11.  
  12. const RSVP_ROUTE = {
  13. path: "/rsvp",
  14. title: "RSVP",
  15. component: RSVP
  16. };
  17.  
  18. const WEDDING_DAY = {
  19. path: "/wedding",
  20. title: "Wedding Day",
  21. component: WeddingDay
  22. };
  23.  
  24. const AFTER_PARTY = {
  25. path: "/after",
  26. title: "After Party",
  27. component: AfterParty
  28. };
  29.  
  30. const ALL_ROUTES = [HOME, RSVP_ROUTE, WEDDING_DAY, AFTER_PARTY];
  31.  
  32. const getTitleByPath = pathname => {
  33. const matchingRoute = ALL_ROUTES.find(route => route.path === pathname);
  34. if (matchingRoute) {
  35. return matchingRoute.title;
  36. }
  37.  
  38. return "";
  39. };
  40.  
  41. export { HOME, RSVP_ROUTE, WEDDING_DAY, AFTER_PARTY, getTitleByPath };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement