mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Merge pull request #4302 from jaswilli/issue-4301
Truncate with ellipsis when metatitle > 70 chars
This commit is contained in:
commit
78788dfaea
@ -102,7 +102,15 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||
seoTitle: Ember.computed('titleScratch', 'metaTitleScratch', function () {
|
||||
var metaTitle = this.get('metaTitleScratch') || '';
|
||||
|
||||
return metaTitle.length > 0 ? metaTitle : this.get('titleScratch');
|
||||
metaTitle = metaTitle.length > 0 ? metaTitle : this.get('titleScratch');
|
||||
|
||||
if (metaTitle.length > 70) {
|
||||
metaTitle = metaTitle.substring(0, 70).trim();
|
||||
metaTitle = Ember.Handlebars.Utils.escapeExpression(metaTitle);
|
||||
metaTitle = new Ember.Handlebars.SafeString(metaTitle + '…');
|
||||
}
|
||||
|
||||
return metaTitle;
|
||||
}),
|
||||
|
||||
seoDescription: Ember.computed('scratch', 'metaDescriptionScratch', function () {
|
||||
@ -139,8 +147,17 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||
return placeholder;
|
||||
}),
|
||||
|
||||
seoSlug: Ember.computed('slug', 'slugPlaceholder', function () {
|
||||
return this.get('slug') ? this.get('slug') : this.get('slugPlaceholder');
|
||||
seoURL: Ember.computed('slug', 'slugPlaceholder', function () {
|
||||
var blogUrl = this.get('config').blogUrl,
|
||||
seoSlug = this.get('slug') ? this.get('slug') : this.get('slugPlaceholder'),
|
||||
seoURL = blogUrl + '/' + seoSlug + '/';
|
||||
|
||||
if (seoURL.length > 70) {
|
||||
seoURL = seoURL.substring(0, 70).trim();
|
||||
seoURL = new Ember.Handlebars.SafeString(seoURL + '…');
|
||||
}
|
||||
|
||||
return seoURL;
|
||||
}),
|
||||
|
||||
// observe titleScratch, keeping the post's slug in sync
|
||||
|
@ -92,7 +92,7 @@
|
||||
<label>Search Engine Result Preview</label>
|
||||
<div class="seo-preview">
|
||||
<div class="seo-preview-title">{{seoTitle}}</div>
|
||||
<div class="seo-preview-link">{{gh-blog-url}}/{{seoSlug}}{{#if seoSlug}}/{{/if}}</div>
|
||||
<div class="seo-preview-link">{{seoURL}}</div>
|
||||
<div class="seo-preview-description">{{seoDescription}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user