mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +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');
|
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),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user