forked from cms/tibi-svelte-starter
Update SLUG field in server side post_create and put_update hooks.
This commit is contained in:
17
api/hooks/lib/helper.js
Normal file
17
api/hooks/lib/helper.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const generateArticleSlugUrlString = (article) => {
|
||||
let slug = article.content.slug
|
||||
let title = article.content.title
|
||||
|
||||
if (!slug || slug === "") {
|
||||
slug = title
|
||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||
.replace(/\s/g, "-")
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
return slug
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateArticleSlugUrlString,
|
||||
}
|
||||
Reference in New Issue
Block a user