Skip to content
Snippets Groups Projects
Commit 3eb1d876 authored by Saif Ali's avatar Saif Ali
Browse files

dynamic slug creation

parent 51e46ea2
No related branches found
No related tags found
No related merge requests found
Pipeline #3168 failed
First version code @ 82657a9f
Subproject commit 82657a9fee126b00afb9da3dab9a1fe4f1361fe9
const titleInput = document.querySelector('input[name=title]');
const slugInput = document.querySelector('input[name=slug]');
const slugify = (val) => {
return val.toString().toLowerCase().trim()
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[\s\W-]+/g, '-') // Replace spaces, non-word characters and dashes with a single dash (-)
};
titleInput.addEventListener('keyup', (e) => {
slugInput.setAttribute('value', slugify(titleInput.value));
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment