tsx
53 lines
1.12 KB
| 1 | import Home from '../components/Home'; |
| 2 | import About from '../components/About'; |
| 3 | import React from 'react'; |
| 4 | import { getAbout, getHome, getContact, getCv } from './api'; |
| 5 | import Contact from '../components/Contact'; |
| 6 | import Cv from '../components/Cv'; |
| 7 | import Firebase from '../components/Firebase'; |
| 8 | |
| 9 | export interface Route { |
| 10 | path: Path; |
| 11 | component: React.ComponentType<any>; |
| 12 | exact?: boolean; |
| 13 | fetchInitialData: (path: Path, firebase: Firebase) => Promise<InitialData>; |
| 14 | } |
| 15 | |
| 16 | export type InitialData = { |
| 17 | data: any; |
| 18 | path: Path; |
| 19 | } |
| 20 | |
| 21 | export enum Path { |
| 22 | HOME = '/', |
| 23 | ABOUT = '/about', |
| 24 | CONTACT = '/contact', |
| 25 | CV = '/cv' |
| 26 | } |
| 27 | |
| 28 | // Desc: Routes for the application |
| 29 | const routes: Route[] = [ |
| 30 | { |
| 31 | path: Path.HOME, |
| 32 | component: Home, |
| 33 | exact: true, |
| 34 | fetchInitialData: getHome |
| 35 | }, |
| 36 | { |
| 37 | path: Path.ABOUT, |
| 38 | component: About, |
| 39 | fetchInitialData: getAbout |
| 40 | }, |
| 41 | { |
| 42 | path: Path.CONTACT, |
| 43 | component: Contact, |
| 44 | fetchInitialData: getContact |
| 45 | }, |
| 46 | { |
| 47 | path: Path.CV, |
| 48 | component: Cv, |
| 49 | fetchInitialData: getCv |
| 50 | } |
| 51 | ]; |
| 52 | |
| 53 | export default routes; |