Sha256: 70019aa3e402db8bb7c2c79b042b5d4fb055725c8f7654d58764e01f16b6142e
Contents?: true
Size: 998 Bytes
Versions: 33
Compression:
Stored size: 998 Bytes
Contents
(() => { const SLUGIFY_REPLACEMENTS = [ [/[àáâã]/g, 'a'], [/ä/g, 'ae'], [/[èéëê]/g, 'e'], [/[ìíïî]/g, 'i'], [/[òóôõ]/g, 'o'], [/ö/g, 'oe'], [/[ùúû]/g, 'u'], [/ü/g, 'ue'], [/ñ/g, 'n'], [/ç/g, 'c'], [/ß/g, 'ss'], [/[·\/,:;_ ]/g, '-'] ]; const slugifyValue = (value) => { let slug = value.trim().toLowerCase(); for (const [from, to] of SLUGIFY_REPLACEMENTS) { slug = slug.replace(from, to); } // Remove any other URL incompatible characters and replace multiple dashes with just a single one. return slug.replace(/[^a-z0-9-]/g, '').replace(/-+/g, '-'); }; window.CMS.slugify = () => { const input = document.querySelector('input[data-slugify=true]'); const slugInput = document.querySelector('input[data-slug]'); if (input === null || slugInput === null) return; input.addEventListener('input', () => { slugInput.value = slugifyValue(input.value); }); }; })();
Version data entries
33 entries across 33 versions & 8 rubygems