I am working on an application where I load 5 articles on a page called stories. When I click an individual story it's supposed to load it's details on the resulting page. Now the stories are coming from a local page (local database) and I use .map to map out all the stores found in the database. This part is fine.
export default {
article: [
{
id: 1,
headline: "Climate Change",
body:"Loren",
},
So this is essentially my "database".
Now upon clicking a story I have my [stories].js page with the following with the code that lets me get the ID of my story, so If I click the climate change story I get the ID of 1.
const SingleStoryPage = () => {
const router = useRouter();
const { storyDetail } = router.query;
The problem is, while I get the ID of 1, I do not know how to specify to only load the climate change story as I am still using map. I know this is of course wrong but, is there a way I can filter on map? something like a where clause where ID = 1 ?
The other examples I looked at loaded the data fine because they used an API and selected the data based on the id which is storyDetail in my case. But seeing as I am not using an API just pulling from a local file. I am not sure how to accomplish this "where" feature.
Any help would be appreciated.