i tried creating a list of categories for my blog using custom types and then creating a relation between my blog_post page type, i've been trying to fetch posts under a category im not sure of how im supposed to achieve that, ideally when each of this category links are clicked it should route it should route to a page like: blog/category/slug and also fetch a list of all the blog posts attached to the custom tye categories
Btw i just started off with using prismic yesterday, pls any help? Thanks
//blog_post page type
"blog_category": {
"type": "Link",
"config": {
"label": "Blog Category",
"select": "document",
"customtypes": ["categories"]
}
}
//categories custom types
{
"format": "custom",
"id": "categories",
"label": "Categories",
"repeatable": true,
"status": true,
"json": {
"Main": {
"uid": {
"config": {
"label": "Slug",
"placeholder": ""
},
"type": "UID"
},
"name": {
"type": "Text",
"config": {
"label": "Name",
"placeholder": ""
}
},
"description": {
"type": "Text",
"config": {
"label": "Description",
"placeholder": ""
}
},
"color": {
"type": "Color",
"config": {
"label": "Color",
"placeholder": ""
}
}
}
}
}
//supposed dynamic category page
export async function getStaticProps({ previewData }) {
const client = createClient({ previewData });
const categories = await client.getAllByType('categories', {
fetchLinks: ['blog_post.body'],
});
return {
props: { categories },
};
}