Slugify config on multiple table not generating findBySlug on Settings
agil3st opened this issue · comments
Slugify config on multiple table not generating findBySlug on Settings. I already did npm run build
but still not generating findBySlug
slugify: {
enabled: true,
config: {
contentTypes: {
product: {
field: 'slug',
references: 'name',
},
blog: {
field: 'slug',
references: 'title',
},
},
},
},
It is okay on product
permission but i can't find findBySlug
in blog
permission settings
I think i misunderstand how to use this plugin. I already modified the blog
controller and did not set a custom route. it should be correct like this without using this plugin
// src/api/blog/controllers/blog.js
module.exports = createCoreController('api::blog.blog', ({ strapi }) => ({
async findBySlug(ctx) {
const { slug } = ctx.params;
const query = {
filters: { slug },
...ctx.query,
populate: "*",
};
const blog = await strapi.entityService.findMany(
"api::blog.blog",
query
);
const { meta } = await super.find(ctx);
const schema = strapi.getModel("api::blog.blog");
const sanitizedEntity = await sanitize.contentAPI.output(blog, schema);
return this.transformResponse(sanitizedEntity[0], meta);
},
}));
// src/api/blog/routes/01-custom-blog.js
module.exports = {
routes: [
{
method: 'GET',
path: '/blogs/find-by-slug/:slug',
handler: 'api::blog.blog.findBySlug',
},
]
};