mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
f07940f0e7
no issue - find+replace to make service injection style consistent and take up much less space at the top of files that used multi-line syntax
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
import Component from '@ember/component';
|
|
import classic from 'ember-classic-decorator';
|
|
import {classNames} from '@ember-decorators/component';
|
|
import {computed} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
/*
|
|
Example usage:
|
|
{{gh-url-preview prefix="tag" slug=theSlugValue tagName="p" classNames="description"}}
|
|
*/
|
|
@classic
|
|
@classNames('ghost-url-preview')
|
|
export default class GhUrlPreview extends Component {
|
|
@service config;
|
|
|
|
prefix = null;
|
|
slug = null;
|
|
|
|
@computed('slug')
|
|
get url() {
|
|
// 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.prefix ? `${this.prefix}/` : '';
|
|
let slug = this.slug ? `${this.slug}/` : '';
|
|
|
|
// Join parts of the URL together with slashes
|
|
let theUrl = `${noSchemeBlogUrl}/${prefix}${slug}`;
|
|
|
|
return theUrl;
|
|
}
|
|
}
|