Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2.  
  3. module.exports.createPages = async ({graphql, actions}) => {
  4.     const { createPage } = actions;
  5.     const artistTemplate = path.resolve('./src/templates/artist.js');
  6.     const res = await graphql(`
  7.         query {
  8.             allContentfulArtist {
  9.             nodes {
  10.                 name
  11.                 picture {
  12.                 file {url}
  13.                 }
  14.                 instagram
  15.                 youTube
  16.                 soundcloud
  17.                 spotify
  18.                 snapchat
  19.             }
  20.             }
  21.         }
  22.     `)
  23.  
  24.     res.data.allContentfulArtist.nodes.forEach(node => {
  25.         createPage({
  26.             component: artistTemplate,
  27.             path: `/${node.name}`,
  28.             context: {
  29.                 name: node.name
  30.             }
  31.         });
  32.     });
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement