static.config.js 778 B

123456789101112131415161718192021222324252627282930313233343536
  1. import path from 'path'
  2. import axios from 'axios'
  3. export default {
  4. getRoutes: async () => {
  5. const { data: posts } = await axios.get(
  6. 'https://jsonplaceholder.typicode.com/posts'
  7. )
  8. return [
  9. {
  10. path: '/blog',
  11. getData: () => ({
  12. posts,
  13. }),
  14. children: posts.map(post => ({
  15. path: `/post/${post.id}`,
  16. template: 'src/containers/Post',
  17. getData: () => ({
  18. post,
  19. }),
  20. })),
  21. },
  22. ]
  23. },
  24. plugins: [
  25. [
  26. require.resolve('react-static-plugin-source-filesystem'),
  27. {
  28. location: path.resolve('./src/pages'),
  29. },
  30. ],
  31. require.resolve('react-static-plugin-reach-router'),
  32. require.resolve('react-static-plugin-sitemap'),
  33. ],
  34. }