I am trying to return in my params the values of the slug and tags , please notice that tags is not an array it's just a string.
export async function getStaticPaths() {
const chapters = await client.fetch(
`*[_type == "chapters" && defined(slug.current)] {
"slug": slug.current,
"tags": tags
}`
);
return {
paths: chapters.map((s : any) => ({params: {slug : s.slug,tags: s.tags}})),
fallback: false,
}
}
So when I try to get the tags value in my getStaticProps I get a null value, yet slug is not null.
export async function getStaticProps(context: any) {
const { slug = "",tags="" } = context.params
const suggestions = await client.fetch(`
*[_type == "chapters" && tags == $tags][0]
`, { tags })
when I try to replace the tags value in getStaticProps with a defined value , it fetches the document successfully ,this means the tags value received from getStaticPaths is null.
How can I solve this issue ?