Closed apophis51 closed 11 months ago
we fixed by changing the old ProgrammingBlogs.page code from:
// async function generateStaticParams(params) {
// const res = await fetch(`https://malcmind-strapi-cms-production.up.railway.app/api/programming-blogs/${params.id}`)
// const post = await res.json()
// console.log(post)
// return post
// }
to
async function generateStaticParams(params) {
let res = await fetch(`https://malcmind-strapi-cms-production.up.railway.app/api/programming-blogs/`)
let post = await res.json()
let blogID = ''
for (let x of post.data){
if (x.attributes.Title.toLowerCase().split(' ').join('-').includes(params.id)){
blogID = x.id
}
}
res = await fetch(`https://malcmind-strapi-cms-production.up.railway.app/api/programming-blogs/${blogID}`)
post = await res.json()
return post
}
Also the calling function in BlogCollection was changed from blogLink = {"/ProgrammingBlogs/${item.id}"}
to blogLink = {
/ProgrammingBlogs/${(item.attributes.Title).toLowerCase().split(' ').join('-')}}
We need to generate urls as
/ProgrammingBlogs/how-to-edit-your-css-with-react-markdown
instead of/ProgrammingBlogs/3