mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
490c0f62b1
Closes #4499 - Introduces a URL preview component - Added the component to tag settings and post settings - Adds a new CSS file for this component which makes sure the preview never wraps onto multiple lines
28 lines
884 B
JavaScript
28 lines
884 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,
|
|
theUrl: null,
|
|
|
|
generateUrl: 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;
|
|
|
|
this.set('the-url', theUrl);
|
|
}.on('didInsertElement').observes('slug')
|
|
});
|
|
|
|
export default urlPreview;
|