Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions docs/developer-docs/latest/guides/slug.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ For that you will have to install `slugify` node module in your application.

When it's done, you have to update the lifecycle of the **Article** Content Type to auto complete the `slug` field.

**Path —** `./api/article/models/Article.js`
**Path —** `./src/api/[api-name]/content-types/[content-type-name]/lifecycles.js`

:::: tabs card

Expand All @@ -71,20 +71,16 @@ When it's done, you have to update the lifecycle of the **Article** Content Type
const slugify = require('slugify');

module.exports = {
/**
* Triggered before user creation.
*/
lifecycles: {
async beforeCreate(data) {
if (data.title) {
data.slug = slugify(data.title, {lower: true});
}
},
async beforeUpdate(params, data) {
if (data.title) {
data.slug = slugify(data.title, {lower: true});
}
},

async beforeCreate(event) {
if (event.params.data.title) {
event.params.data.slug = slugify(event.params.data.title, { lower: true });
}
},
async beforeUpdate(event) {
if (event.params.data.Titel) {
event.params.data.slug = slugify(event.params.data.title, { lower: true });
}
},
};
```
Expand Down