summaryrefslogtreecommitdiff
path: root/src/helpers/slug.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/slug.js')
-rw-r--r--src/helpers/slug.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/helpers/slug.js b/src/helpers/slug.js
new file mode 100644
index 00000000..5a8db08f
--- /dev/null
+++ b/src/helpers/slug.js
@@ -0,0 +1,13 @@
+const createSlug = (name, id) => {
+ return name.trim().replace(new RegExp(/[^A-Za-z0-9]/, 'g'), '-').toLowerCase() + '-' + id;
+}
+
+const getId = (slug) => {
+ let id = slug.split('-');
+ return id[id.length-1];
+}
+
+export {
+ createSlug,
+ getId
+}; \ No newline at end of file