mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Update slug.md
This commit is contained in:
parent
8d01c1029c
commit
026b91a99b
@ -63,17 +63,15 @@ When it's done, you have to update the life cycle of the **Article** Content Typ
|
||||
const slugify = require('slugify');
|
||||
|
||||
module.exports = {
|
||||
beforeSave: async model => {
|
||||
if (model.title) {
|
||||
model.slug = slugify(model.title);
|
||||
lifecycles: {
|
||||
beforeCreate: async (data) => {
|
||||
if (data.title) {
|
||||
data.slug = slugify(data.title);
|
||||
}
|
||||
},
|
||||
beforeUpdate: async model => {
|
||||
if (model.getUpdate() && model.getUpdate().title) {
|
||||
model.update({
|
||||
slug: slugify(model.getUpdate().title),
|
||||
});
|
||||
}
|
||||
beforeUpdate: async (params, data) => {
|
||||
data.slug = slugify(data.title);
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user