type findIndex
parent
0c21c1bc6b
commit
ff82456c67
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue