mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
3f361f8742
no issue - drops the `var Foo = Ember.Thing.extend({}); export default Foo;` syntax in favour of exporting directly, eg: `export default Ember.Thing.extend({})` - discussion on this change [here](https://github.com/TryGhost/Ghost/pull/5340#issuecomment-105828423) and [here](https://github.com/TryGhost/Ghost/pull/5694#discussion-diff-37511606)
28 lines
868 B
JavaScript
28 lines
868 B
JavaScript
import Ember from 'ember';
|
|
/*
|
|
Example usage:
|
|
{{gh-url-preview prefix="tag" slug=theSlugValue tagName="p" classNames="description"}}
|
|
*/
|
|
export default Ember.Component.extend({
|
|
classNames: 'ghost-url-preview',
|
|
prefix: null,
|
|
slug: null,
|
|
|
|
config: Ember.inject.service(),
|
|
|
|
url: Ember.computed('slug', function () {
|
|
// Get the blog URL and strip the scheme
|
|
var blogUrl = this.get('config.blogUrl'),
|
|
noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3), // Remove `http[s]://`
|
|
|
|
// Get the prefix and slug values
|
|
prefix = this.get('prefix') ? this.get('prefix') + '/' : '',
|
|
slug = this.get('slug') ? this.get('slug') + '/' : '',
|
|
|
|
// Join parts of the URL together with slashes
|
|
theUrl = noSchemeBlogUrl + '/' + prefix + slug;
|
|
|
|
return theUrl;
|
|
})
|
|
});
|