refactor: review data

This commit is contained in:
2021-02-07 10:46:48 +00:00
parent b90808d118
commit cd2ee79043
4 changed files with 50 additions and 36 deletions

View File

@@ -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: [

View File

@@ -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 {

25
src/data/reviews.json Normal file
View File

@@ -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"
}
]
}

View File

@@ -114,7 +114,7 @@ export default function Index({ data }) {
</Section>
<Section variant="primary" heading="What our clients think of us">
<CustomSlick>
{data.site.siteMetadata.reviews.map((review, i) => (
{data.allReview.nodes.map((review, i) => (
<ReviewSummary key={i} review={review} />
))}
</CustomSlick>
@@ -179,15 +179,13 @@ export const query = graphql`
}
}
}
site {
siteMetadata {
reviews {
name
title
text
allReview {
nodes {
author
date
}
name
text
title
}
}
}