{"size": 1749, "ext": "js", "max_stars_repo_path": "gatsby-node.js", "max_stars_repo_name": "jiaaiji/takeaways", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gatsby-node.js", "max_issues_repo_name": "jiaaiji/takeaways", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gatsby-node.js", "max_forks_repo_name": "jiaaiji/takeaways", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.0131578947, "max_line_length": 73, "alphanum_fraction": 0.5563178959}
const path = require(`path`);
const { paginate } = require("gatsby-awesome-pagination");

// Log out information after a build is done
exports.onPostBuild = ({ reporter }) => {
  reporter.info(`Your Gatsby site has been built!`);
};

// Create blog pages dynamically
exports.createPages = async ({ graphql, actions }) => {
  const { createPage } = actions;

  // Create Places
  const indexTemplate = path.resolve(`src/templates/index.tsx`);
  const placeTemplate = path.resolve(`src/templates/places.tsx`);

  const allPlaces = await graphql(`
    query {
      allContentfulPlace(
        filter: { node_locale: { eq: "ja-JP" } }
        sort: { fields: updatedAt, order: DESC }
      ) {
        edges {
          node {
            id
          }
        }
      }
    }
  `);

  paginate({
    createPage,
    items: allPlaces.data.allContentfulPlace.edges,
    itemsPerPage: 10,
    pathPrefix: ({ pageNumber, _ }) =>
      pageNumber === 0 ? "/" : "/places/page",
    component: indexTemplate
  });

  allPlaces.data.allContentfulPlace.edges.forEach(edge => {
    createPage({
      path: `places/${edge.node.id}`,
      component: placeTemplate,
      context: {
        id: edge.node.id
      }
    });
  });

  // Create Tags
  const tagsTemplate = path.resolve(`src/templates/tags.tsx`);
  (
    await graphql(`
      query {
        allContentfulPlaceTag(filter: { node_locale: { eq: "ja-JP" } }) {
          edges {
            node {
              name
              slug
            }
          }
        }
      }
    `)
  ).data.allContentfulPlaceTag.edges.forEach(edge => {
    createPage({
      path: `tags/${edge.node.slug}`,
      component: tagsTemplate,
      context: {
        slug: edge.node.slug
      }
    });
  });
};
