0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed missing seo description in post preview modal

refs https://github.com/TryGhost/Team/issues/459

- the SERP description was not falling back to the server-side generated `excerpt` field on the post
- removed outdated dynamic description generation from markdown card, should be replaced with dynamic description generation from mobiledoc if needed
This commit is contained in:
Kevin Ansfield 2021-02-01 09:23:10 +00:00 committed by Daniel Lockyer
parent 4108ec735a
commit e8970841d2

View file

@ -1,5 +1,4 @@
import Component from '@glimmer/component'; import Component from '@glimmer/component';
import formatMarkdown from 'ghost-admin/utils/format-markdown';
import {inject as service} from '@ember/service'; import {inject as service} from '@ember/service';
export default class ModalPostPreviewSocialComponent extends Component { export default class ModalPostPreviewSocialComponent extends Component {
@ -9,7 +8,6 @@ export default class ModalPostPreviewSocialComponent extends Component {
get _fallbackDescription() { get _fallbackDescription() {
return this.args.post.customExcerpt || return this.args.post.customExcerpt ||
this.serpDescription || this.serpDescription ||
this.args.post.excerpt ||
this.settings.get('description'); this.settings.get('description');
} }
@ -43,27 +41,7 @@ export default class ModalPostPreviewSocialComponent extends Component {
} }
get serpDescription() { get serpDescription() {
const metaDescription = this.args.post.metaDescription; return this.args.post.metaDescription || this.args.post.excerpt;
if (metaDescription) {
return metaDescription;
}
const mobiledoc = this.args.post.scratch;
const [markdownCard] = (mobiledoc && mobiledoc.cards) || [];
const markdown = markdownCard && markdownCard[1] && markdownCard[1].markdown;
let serpDescription;
const div = document.createElement('div');
div.innerHTML = formatMarkdown(markdown, false);
// Strip HTML
serpDescription = div.textContent;
// Replace new lines and trim
serpDescription = serpDescription.replace(/\n+/g, ' ').trim();
return serpDescription;
} }
// Facebook // Facebook