ea9c8c03fe
refs https://github.com/TryGhost/Ghost/pull/15550 Pulled out of the rolled up node+ember-js+ember-template rollup linter update PR as it required fairly extensive changes. - bumped package - renamed `no-down-event-binding` to `no-pointer-down-event-binding` - disabled `no-pointer-down-event-binding` rule - disabled `no-triple-curlies` rule - ran `yarn lint:hbs --fix` - updated integration tests to match Octane syntax - fixed various one-off errors - updated .lint-todo
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} from 'ghost-admin/decorators/inject';
|
|
|
|
/*
|
|
Example usage:
|
|
<GhUrlPreview @prefix="tag" @slug={{theSlugValue}} @tagName="p" @classNames="description" />
|
|
*/
|
|
@classic
|
|
@classNames('ghost-url-preview')
|
|
export default class GhUrlPreview extends Component {
|
|
@inject config;
|
|
|
|
prefix = null;
|
|
slug = null;
|
|
|
|
@computed('slug')
|
|
get url() {
|
|
// Get the blog URL and strip the scheme
|
|
let blogUrl = this.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;
|
|
}
|
|
}
|