From ab6241f4d435e18cdcfeaedc11436f4da7f50d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Fri, 13 May 2022 02:39:32 +0400 Subject: [PATCH] Fix artiste slug --- src/api/artiste/content-types/artiste/lifecycles.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/artiste/content-types/artiste/lifecycles.js b/src/api/artiste/content-types/artiste/lifecycles.js index ed71fc3..ffb51a2 100644 --- a/src/api/artiste/content-types/artiste/lifecycles.js +++ b/src/api/artiste/content-types/artiste/lifecycles.js @@ -23,8 +23,10 @@ module.exports = { let {data} = event.params - if (!data.slug || data.slug !== slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})) { - data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g}) + if(!data.publishedAt) { + if (!data.slug || data.slug !== slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})) { + data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g}) + } } }, beforeCreate: async event => { @@ -33,7 +35,6 @@ module.exports = { data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g}) }, afterUpdate: async event => { - console.log('event', event) let {data} = event.params const {id} = data const artiste = await jwennAwtisEpiId(id)