I have a json file for blog posts, the json file will be getting updated from time to time with new items…
I want to map through the json file, then extract just a single item return the values to fill a component props…
The problem??? When I map it, the return is for ALL the items in the list… is there a way I can return just a single item???
*** keep in mind that json will be changing *** I have been trying to tap into the value of the item id… but I haven’t been able to make it work…
The sample code I have is this:
import React from "react";
import Blogger11 from "../../../components/blog-post-english1";
import db from "../../../utils/blogs-front/spanish/blog-spanis1.json";
export async function getStaticProps() {
return {
props: { db },
};
}
const PostTest = ({ db }) => {
return (
<div>
{db.map((item) => {
return (
<Blogger11
key={item.id[1]}
metaTitle={item.metaTitle}
metaDescription={item.metaDescription}
metaKeywords={item.metaKeywords}
ogTitle={item.ogTitle}
ogDescription={item.ogDescription}
ogURL={item.ogURL}
ogImage={item.ogImage}
twitterTitle={item.twitterTitle}
twitterDescription={item.twitterDescription}
twitterImage={item.twitterImage}
title={item.title}
body={item.body}
description={item.Description}
previous={item.previous}
next={item.next}
/>
);
})}
;
</div>
);
};
export default PostTest;