mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
2f4f6db133
no issue - add ember-suave dependency - upgrade grunt-jscs dependency - add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc - separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc - standardize es6 usage across client
32 lines
897 B
JavaScript
32 lines
897 B
JavaScript
import Ember from 'ember';
|
|
|
|
const {Component, computed, inject} = Ember;
|
|
|
|
/*
|
|
Example usage:
|
|
{{gh-url-preview prefix="tag" slug=theSlugValue tagName="p" classNames="description"}}
|
|
*/
|
|
export default Component.extend({
|
|
classNames: 'ghost-url-preview',
|
|
prefix: null,
|
|
slug: null,
|
|
|
|
config: inject.service(),
|
|
|
|
url: computed('slug', function () {
|
|
// Get the blog URL and strip the scheme
|
|
let blogUrl = this.get('config.blogUrl');
|
|
// Remove `http[s]://`
|
|
let noSchemeBlogUrl = blogUrl.substr(blogUrl.indexOf('://') + 3);
|
|
|
|
// Get the prefix and slug values
|
|
let prefix = this.get('prefix') ? `${this.get('prefix')}/` : '';
|
|
let slug = this.get('slug') ? `${this.get('slug')}/` : '';
|
|
|
|
// Join parts of the URL together with slashes
|
|
let theUrl = `${noSchemeBlogUrl}/${prefix}${slug}`;
|
|
|
|
return theUrl;
|
|
})
|
|
});
|