slug from unicode chars

This commit is contained in:
Vaclav Klecanda 2017-05-09 09:36:40 +02:00 committed by David Calavera
parent ab47c3c8b3
commit 018616dc68
2 changed files with 4 additions and 2 deletions

View File

@ -160,6 +160,7 @@
"semaphore": "^1.0.5", "semaphore": "^1.0.5",
"slate": "^0.14.14", "slate": "^0.14.14",
"slate-drop-or-paste-images": "^0.2.0", "slate-drop-or-paste-images": "^0.2.0",
"slug": "^0.9.1",
"textarea-caret-position": "^0.1.1", "textarea-caret-position": "^0.1.1",
"uuid": "^2.0.3", "uuid": "^2.0.3",
"whatwg-fetch": "^1.0.0" "whatwg-fetch": "^1.0.0"

View File

@ -4,6 +4,7 @@ import NetlifyAuthBackend from "./netlify-auth/implementation";
import { resolveFormat } from "../formats/formats"; import { resolveFormat } from "../formats/formats";
import { selectListMethod, selectEntrySlug, selectEntryPath, selectAllowNewEntries, selectFolderEntryExtension } from "../reducers/collections"; import { selectListMethod, selectEntrySlug, selectEntryPath, selectAllowNewEntries, selectFolderEntryExtension } from "../reducers/collections";
import { createEntry } from "../valueObjects/Entry"; import { createEntry } from "../valueObjects/Entry";
import slug from 'slug';
class LocalStorageAuthStore { class LocalStorageAuthStore {
storageKey = "netlify-cms-user"; storageKey = "netlify-cms-user";
@ -34,9 +35,9 @@ const slugFormatter = (template = "{{slug}}", entryData) => {
case "day": case "day":
return (`0${ date.getDate() }`).slice(-2); return (`0${ date.getDate() }`).slice(-2);
case "slug": case "slug":
return identifier.trim().toLowerCase().replace(/[^a-z0-9\-_]+/gi, "-"); return slug(identifier.trim(), {lower: true});
default: default:
return entryData.get(field, "").trim().toLowerCase().replace(/[^a-z0-9\.\-_]+/gi, "-"); return slug(entryData.get(field, "").trim(), {lower: true});
} }
}); });
}; };