refactor on slugformatter

This commit is contained in:
Cássio Zen
2016-10-27 13:12:18 -02:00
parent dabf6a1be1
commit baafe0b32f
5 changed files with 42 additions and 33 deletions

View File

@ -86,8 +86,8 @@ class Backend {
}
// We have the file path. Fetch and parse the file.
getEntry(collection, slug, path) {
return this.implementation.getEntry(collection, slug, path)
getEntry(collection, slug) {
return this.implementation.getEntry(collection, slug, new Collection(collection).entryPath(slug))
.then(loadedEntry => this.entryWithFormat(collection, slug)(createEntry(
collection.get('name'),
slug,
@ -97,10 +97,6 @@ class Backend {
);
}
lookupEntry(collection, slug) {
return this.getEntry(collection, slug, new Collection(collection).entryPath(slug));
}
newEntry(collection) {
return createEntry(collection.get('name'));
}
@ -197,11 +193,11 @@ export function resolveBackend(config) {
switch (name) {
case 'test-repo':
return new Backend(new TestRepoBackend(config, slugFormatter), authStore);
return new Backend(new TestRepoBackend(config), authStore);
case 'github':
return new Backend(new GitHubBackend(config, slugFormatter), authStore);
return new Backend(new GitHubBackend(config), authStore);
case 'netlify-git':
return new Backend(new NetlifyGitBackend(config, slugFormatter), authStore);
return new Backend(new NetlifyGitBackend(config), authStore);
default:
throw new Error(`Backend not found: ${ name }`);
}