mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
5553f4f6fe
No Issue - Rework the preview URL component so its implementation is simpler. - Add test for gh-url-preview component. - ember-mocha@0.3.0. - Remove unused jshint options.
27 lines
834 B
JavaScript
27 lines
834 B
JavaScript
/*
|
|
Example usage:
|
|
{{gh-url-preview prefix="tag" slug=theSlugValue tagName="p" classNames="description"}}
|
|
*/
|
|
var urlPreview = Ember.Component.extend({
|
|
classNames: 'ghost-url-preview',
|
|
prefix: null,
|
|
slug: null,
|
|
|
|
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;
|
|
})
|
|
});
|
|
|
|
export default urlPreview;
|