I have integrated my React-hooks
website with contentful
. Now I am able to see contents from contentful website in my react site. On click on ...more >>
link under each tile I would like to display the contents received to open in a separate
html page, so that I can view full content of the post. Can someone please advise me on how can I achieve that ? ( Home tab > screenshot of tiles )
Demo
https://codesandbox.io/s/optimistic-lamarr-fo917
Home.js
import React, { useState, useEffect } from "react";
import "./styles.css";
const items = [
{
sys: {
space: {
sys: {
type: "Link",
linkType: "Space",
id: "pih85ghtkifg"
}
},
id: "2L5jhZhtvUwuWe20kYM2vh",
type: "Entry",
createdAt: "2020-09-20T11:50:53.764Z",
updatedAt: "2020-09-20T11:50:53.764Z",
environment: {
sys: {
id: "master",
type: "Link",
linkType: "Environment"
}
},
revision: 1,
contentType: {
sys: {
type: "Link",
linkType: "ContentType",
id: "course"
}
},
locale: "en-US"
},
fields: {
title: "API testing using Postman",
slug: "api-testing-using-postman",
image: {
sys: {
type: "Link",
linkType: "Asset",
id: "6n41KgxfwWmmeCiSemIsK2"
}
},
shortDescription: "Cypress test to read a JSON file from Fixture folder.",
description:
"Api testing using postman. This is useful for testers.\n\npm.test()\n\nApi testing using postman. This is useful for testers. \n",
duration: 3,
skillLevel: "beginner",
lessons: [
{
sys: {
type: "Link",
linkType: "Entry",
id: "3op5VIqGZiwoe06c8IQIMO"
}
}
],
categories: [
{
sys: {
type: "Link",
linkType: "Entry",
id: "7JhDodrNmwmwGmQqiACW4"
}
}
]
}
},
{
sys: {
space: {
sys: {
type: "Link",
linkType: "Space",
id: "pih85ghtkifg"
}
},
id: "1ePcCVp2VzehrXpcSaq6aM",
type: "Entry",
createdAt: "2020-09-20T08:43:44.388Z",
updatedAt: "2020-09-20T08:43:44.388Z",
environment: {
sys: {
id: "master",
type: "Link",
linkType: "Environment"
}
},
revision: 1,
contentType: {
sys: {
type: "Link",
linkType: "ContentType",
id: "course"
}
},
locale: "en-US"
},
fields: {
title: "Cypress test to read a JSON file",
slug: "cypress-test-to-read-a-json-file",
image: {
sys: {
type: "Link",
linkType: "Asset",
id: "6n41KgxfwWmmeCiSemIsK2"
}
},
shortDescription: "Cypress test to read a JSON file from Fixture folder.",
description:
"\nThis cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. \n\n> cy.get()\n\nThis cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. This cy test is to read a JSON file from fixture folder. \n",
duration: 3,
skillLevel: "beginner",
lessons: [
{
sys: {
type: "Link",
linkType: "Entry",
id: "3op5VIqGZiwoe06c8IQIMO"
}
}
],
categories: [
{
sys: {
type: "Link",
linkType: "Entry",
id: "7JhDodrNmwmwGmQqiACW4"
}
}
]
}
}
];
const Home = () => {
const [blogArticles, setBlogArticles] = useState([]);
useEffect(() => {
setBlogArticles(items);
}, []);
return (
<div className="App">
<div className="container">
{blogArticles.map(
({
sys: { id },
fields: {
title,
image,
shortDescription,
description,
skillLevel,
duration
}
}) => (
<div key={id} className="column-center">
<article key={id} className="blogmaintile">
<img
className="blogImage"
key={image}
src={image}
alt="myimg"
></img>
<div className="blogtitle">
<span key={title}>{title}</span>
</div>
<section>
<p className="blogdescription" key={shortDescription}>
{shortDescription}
</p>
</section>
<section>
<p className="blogdescription" key={description}>
{description}
</p>
</section>
<section className="col2">
<a href="">
Read more {">"}
{">"}
</a>
</section>
</article>
</div>
)
)}
</div>
</div>
);
}
export default Home;