Created
March 23, 2018 20:08
-
-
Save ivanoats/e770576e18bd579d88d7d8c5d66abad2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import fetch from 'node-fetch' | |
import axios from 'axios' | |
export default { | |
getSiteData: () => ({ | |
title: 'React Static Large JSON test' | |
}), | |
getRoutes: async () => { | |
const { data: locations } = await axios.get( | |
'http://localhost:3001/locations', | |
{ | |
headers: { | |
'Access-Control-Allow-Origin': '*' | |
} | |
} | |
) | |
return [ | |
{ | |
path: '/', | |
component: 'src/containers/Home' | |
}, | |
{ | |
path: '/about', | |
component: 'src/containers/About' | |
}, | |
{ | |
path: '/location', | |
component: 'src/containers/Blog', | |
getData: async () => ({ | |
locations | |
}), | |
children: locations.map(location => ({ | |
path: `/${location.id}`, | |
component: 'src/containers/Post', | |
getData: async () => ({ | |
location | |
}) | |
})) | |
}, | |
{ | |
is404: true, | |
component: 'src/containers/404' | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment