diff --git a/package.json b/package.json index 39c06346..b7ff5eb5 100644 --- a/package.json +++ b/package.json @@ -160,6 +160,7 @@ "semaphore": "^1.0.5", "slate": "^0.14.14", "slate-drop-or-paste-images": "^0.2.0", + "slug": "^0.9.1", "textarea-caret-position": "^0.1.1", "uuid": "^2.0.3", "whatwg-fetch": "^1.0.0" diff --git a/src/backends/backend.js b/src/backends/backend.js index cddeab18..1eb6de41 100644 --- a/src/backends/backend.js +++ b/src/backends/backend.js @@ -4,6 +4,7 @@ import NetlifyAuthBackend from "./netlify-auth/implementation"; import { resolveFormat } from "../formats/formats"; import { selectListMethod, selectEntrySlug, selectEntryPath, selectAllowNewEntries, selectFolderEntryExtension } from "../reducers/collections"; import { createEntry } from "../valueObjects/Entry"; +import slug from 'slug'; class LocalStorageAuthStore { storageKey = "netlify-cms-user"; @@ -34,9 +35,9 @@ const slugFormatter = (template = "{{slug}}", entryData) => { case "day": return (`0${ date.getDate() }`).slice(-2); case "slug": - return identifier.trim().toLowerCase().replace(/[^a-z0-9\-_]+/gi, "-"); + return slug(identifier.trim(), {lower: true}); default: - return entryData.get(field, "").trim().toLowerCase().replace(/[^a-z0-9\.\-_]+/gi, "-"); + return slug(entryData.get(field, "").trim(), {lower: true}); } }); };