mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #4302 from jaswilli/issue-4301
Truncate with ellipsis when metatitle > 70 chars
This commit is contained in:
commit
a27cadd0bd
2 changed files with 21 additions and 4 deletions
|
@ -102,7 +102,15 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||||
seoTitle: Ember.computed('titleScratch', 'metaTitleScratch', function () {
|
seoTitle: Ember.computed('titleScratch', 'metaTitleScratch', function () {
|
||||||
var metaTitle = this.get('metaTitleScratch') || '';
|
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 () {
|
seoDescription: Ember.computed('scratch', 'metaDescriptionScratch', function () {
|
||||||
|
@ -139,8 +147,17 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
|
||||||
return placeholder;
|
return placeholder;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
seoSlug: Ember.computed('slug', 'slugPlaceholder', function () {
|
seoURL: Ember.computed('slug', 'slugPlaceholder', function () {
|
||||||
return this.get('slug') ? this.get('slug') : this.get('slugPlaceholder');
|
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
|
// observe titleScratch, keeping the post's slug in sync
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
<label>Search Engine Result Preview</label>
|
<label>Search Engine Result Preview</label>
|
||||||
<div class="seo-preview">
|
<div class="seo-preview">
|
||||||
<div class="seo-preview-title">{{seoTitle}}</div>
|
<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 class="seo-preview-description">{{seoDescription}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue