Ghost/core/client/models/slug-generator.js
Maurice Williams 489cd08d97 custom slugging capabilities for individual user pages
closes #3401
- modifying slug-generator to be more generic
- adding slugging capabilities for /settings/users/:slug
- modified posts to use the updated slug-generator
2014-07-31 08:14:22 -04:00

29 lines
717 B
JavaScript

var SlugGenerator = Ember.Object.extend({
ghostPaths: null,
slugType: null,
value: null,
toString: function () {
return this.get('value');
},
generateSlug: function (textToSlugify) {
var self = this,
url;
if (!textToSlugify) {
return Ember.RSVP.resolve('');
}
url = this.get('ghostPaths.url').api('slugs', this.get('slugType'), encodeURIComponent(textToSlugify));
return ic.ajax.request(url, {
type: 'GET'
}).then(function (response) {
var slug = response.slugs[0].slug;
self.set('value', slug);
return slug;
});
}
});
export default SlugGenerator;