Last active
June 30, 2019 21:57
-
-
Save alexjamesbrown/ed594980566407d6ee369dcd76539f45 to your computer and use it in GitHub Desktop.
Slugify function for Google Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Slugify(title, date) { | |
if (!title) | |
return ""; | |
if(!date) | |
return ""; | |
slug = ''; | |
var months = [ "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" ]; | |
value = title + "-" + date.getDate() + "-" + months[date.getMonth()] + "-" + date.getYear(); | |
slug = value.toLowerCase(); | |
slug = slug.replace(/[^\w\s-]/g, ''); | |
slug = slug.replace(/\s+/g, '-'); | |
return slug; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment