diff --git a/gatsby-config.js b/gatsby-config.js index ed44595..3e8fd51 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -39,32 +39,6 @@ module.exports = { title: "Contact", to: "/contact" } - ], - reviews: [ - { - name: "Rated People", - title: "Bathroom fitter", - text: - "I am so pleased with my bathroom. This is the second time I have used this company. The first time they did both my bathrooms and they looked incredible. This time they installed under floor heating and also did the tiling. They go way above what they need to do, always making great suggestions. They even let me use there trade card at top tiles so I could save money. Would 100% recommend these guys.", - author: "Lee", - date: "01/01/2021" - }, - { - name: "Rated People", - title: "Tiler", - text: - "Nick and Daniel agreed to level and tile my kitchen floor at very short notice. The quote was very competitively priced and Daniel's workmanship is exceptional. I would definitely recommend them.", - author: "Daniel", - date: "21/12/2020" - }, - { - name: "Bark", - title: "New bathroom", - text: - "Excellent, my mother's bathroom was gutted and refitted in 7 days. They tiled the necessary areas shower, the floor, a quadrant shower fitted, new sink and toilet fitted. A new ceiling with 4 spot lights and remaining walls plastered and painted. They also fitted a heated towel rail and mirrored cabinet. My mother was delighted and so was I to see her smile at her new bathroom. Worked cleanly and removed all the old bathroom. Very friendly and provided a quick quote. Would highly recommend.", - author: "Mrs Wittiker", - date: "10/01/2021" - } ] }, plugins: [ diff --git a/gatsby-node.js b/gatsby-node.js index f7c586e..c91fb98 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,7 +1,24 @@ const { resolve } = require("path"); +const reviews = require("./src/data/reviews.json"); const caseStudies = require("./src/data/case-studies.json"); exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => { + reviews.reviews.forEach((review, i) => { + const { name, title, text, author, date } = review; + const node = { + name, + title, + text, + author, + date, + id: createNodeId(`review-${i}`), + internal: { + type: "review", + contentDigest: createContentDigest(review) + } + }; + actions.createNode(node); + }); Object.keys(caseStudies).forEach(key => { caseStudies[key].forEach((cs, i) => { const { diff --git a/src/data/reviews.json b/src/data/reviews.json new file mode 100644 index 0000000..6bed3ec --- /dev/null +++ b/src/data/reviews.json @@ -0,0 +1,25 @@ +{ + "reviews": [ + { + "name": "Rated People", + "title": "Bathroom fitter", + "text": "I am so pleased with my bathroom. This is the second time I have used this company. The first time they did both my bathrooms and they looked incredible. This time they installed under floor heating and also did the tiling. They go way above what they need to do, always making great suggestions. They even let me use there trade card at top tiles so I could save money. Would 100% recommend these guys.", + "author": "Lee", + "date": "01/01/2021" + }, + { + "name": "Rated People", + "title": "Tiler", + "text": "Nick and Daniel agreed to level and tile my kitchen floor at very short notice. The quote was very competitively priced and Daniel's workmanship is exceptional. I would definitely recommend them.", + "author": "Daniel", + "date": "21/12/2020" + }, + { + "name": "Bark", + "title": "New bathroom", + "text": "Excellent, my mother's bathroom was gutted and refitted in 7 days. They tiled the necessary areas shower, the floor, a quadrant shower fitted, new sink and toilet fitted. A new ceiling with 4 spot lights and remaining walls plastered and painted. They also fitted a heated towel rail and mirrored cabinet. My mother was delighted and so was I to see her smile at her new bathroom. Worked cleanly and removed all the old bathroom. Very friendly and provided a quick quote. Would highly recommend.", + "author": "Mrs Wittiker", + "date": "10/01/2021" + } + ] +} diff --git a/src/pages/index.js b/src/pages/index.js index a601bb7..4097596 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -114,7 +114,7 @@ export default function Index({ data }) {
- {data.site.siteMetadata.reviews.map((review, i) => ( + {data.allReview.nodes.map((review, i) => ( ))} @@ -179,15 +179,13 @@ export const query = graphql` } } } - site { - siteMetadata { - reviews { - name - title - text - author - date - } + allReview { + nodes { + author + date + name + text + title } } }