type findIndex

master
Suvodip Ghosh 2023-02-10 00:09:53 +05:30
parent 0c21c1bc6b
commit ff82456c67
1 changed files with 2 additions and 2 deletions

View File

@ -7,12 +7,12 @@ export async function getStaticPaths() {
const finalData = data.data.map((n: { slug: any; })=>{
return {params: {id:n.slug}}
})
console.log(finalData)
// console.log(finalData)
return finalData;
}
const { id } = Astro.params;
const idx = data.data.findIndex(n => n.slug ===id);
const idx = data.data.findIndex((n: { slug: string | undefined; }) => n.slug ===id);
---
<h1>{id}</h1>
{data.data[idx].slug} <br>