Update slug.md

This commit is contained in:
Rodrigo José Carvalho de Mello 2020-06-02 20:49:26 -03:00 committed by GitHub
parent 8d01c1029c
commit 026b91a99b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,17 +63,15 @@ When it's done, you have to update the life cycle of the **Article** Content Typ
const slugify = require('slugify'); const slugify = require('slugify');
module.exports = { module.exports = {
beforeSave: async model => { lifecycles: {
if (model.title) { beforeCreate: async (data) => {
model.slug = slugify(model.title); if (data.title) {
data.slug = slugify(data.title);
} }
}, },
beforeUpdate: async model => { beforeUpdate: async (params, data) => {
if (model.getUpdate() && model.getUpdate().title) { data.slug = slugify(data.title);
model.update({ },
slug: slugify(model.getUpdate().title),
});
}
}, },
}; };
``` ```