From 4647344e93094a2fa310f8d09c9a33d29c4e7779 Mon Sep 17 00:00:00 2001 From: Iris Ibekwe Date: Tue, 13 Oct 2020 08:26:51 -0400 Subject: [PATCH] Change data source to the new Strapi instance. --- gatsby-config.js | 12 +++++++++--- gatsby-node.js | 7 ++++--- src/components/RelatedRecipes.jsx | 16 ++++++++-------- src/components/layout.jsx | 5 ++--- src/pages/recipes/index.jsx | 8 ++++---- src/templates/recipes.jsx | 12 ++++++------ 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 6c5076e..5c36548 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -21,11 +21,17 @@ module.exports = { { resolve: 'gatsby-source-strapi', options: { - apiURL: 'https://fe-knowledgebase-cms.herokuapp.com', + apiURL: 'https://fe-strapi.herokuapp.com', + queryLimit: 1000, contentTypes: [ - 'recipe', + 'recipes', 'user' - ] + ], + singleTypes: [], + loginData: { + identifier: "", + password: "", + }, } }, { diff --git a/gatsby-node.js b/gatsby-node.js index 4178c10..3d3a2e0 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -12,13 +12,13 @@ exports.createPages = async ({ graphql, actions }) => { const recipeTemplate = path.resolve(`src/templates/recipes.jsx`); const result = await graphql(` query { - allStrapiRecipe { + allStrapiRecipes { edges { node { Title Body Tags - author { + Author { username } created_at @@ -28,7 +28,8 @@ exports.createPages = async ({ graphql, actions }) => { } } `) - result.data.allStrapiRecipe.edges.forEach(edge => { + console.log(result.data); + result.data.allStrapiRecipes.edges.forEach(edge => { let slug = edge.node.Title.replace(/\s+/g, '-').toLowerCase(); createPage({ path: `recipes/${slug}`, diff --git a/src/components/RelatedRecipes.jsx b/src/components/RelatedRecipes.jsx index 50dade7..8fa5dcf 100644 --- a/src/components/RelatedRecipes.jsx +++ b/src/components/RelatedRecipes.jsx @@ -2,11 +2,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { graphql, Link, StaticQuery } from 'gatsby'; -const RelatedRecipies = ({ tag }) => ( +const RelatedRecipes = ({ tag }) => ( ( `} render={(data) => { const related = []; - Object.keys(data.allStrapiRecipe.edges).forEach((id) => { - if (data.allStrapiRecipe.edges[id].node.Tags === tag) { + Object.keys(data.allStrapiRecipes.edges).forEach((id) => { + if (data.allStrapiRecipes.edges[id].node.Tags === tag) { related.push(

- { data.allStrapiRecipe.edges[id].node.Title } + { data.allStrapiRecipes.edges[id].node.Title }

, ); @@ -48,8 +48,8 @@ const RelatedRecipies = ({ tag }) => ( /> ); -export default RelatedRecipies; +export default RelatedRecipes; -RelatedRecipies.propTypes = { +RelatedRecipes.propTypes = { tag: PropTypes.string.isRequired, }; diff --git a/src/components/layout.jsx b/src/components/layout.jsx index cb74b62..608fa54 100644 --- a/src/components/layout.jsx +++ b/src/components/layout.jsx @@ -8,11 +8,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useStaticQuery, graphql } from 'gatsby'; -import RelatedRecipies from './RelatedRecipes'; import Header from './header/header'; import '../sass/styles.scss'; import '../sass/components/layout.scss'; - +import RelatedRecipes from './RelatedRecipes'; const Layout = ({ children, tag }) => { const data = useStaticQuery(graphql` @@ -36,7 +35,7 @@ const Layout = ({ children, tag }) => { }} >
{children}
- {tag ? : '' } + {tag ? : '' }