Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. exports.createPages = async function({ actions, graphql }) {
  2. const { data } = await graphql(`
  3. query {
  4. swapi {
  5. posts {
  6. title
  7. description
  8. created_at
  9. id
  10. }
  11. }
  12. }
  13. `)
  14. data.swapi.posts.forEach(post => {
  15. const slug = post.id
  16. actions.createPage({
  17. path: `/post/${slug}`,
  18. component: require.resolve(`./src/components/PostLayout.js`),
  19. context: { slug: slug },
  20. })
  21. })
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement