18 lines
364 B
JavaScript
18 lines
364 B
JavaScript
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,
|
|
}
|