From de76f4b7a5035670d7e4a7da21baa3200aec504c Mon Sep 17 00:00:00 2001 From: Ravigopal Kesari Date: Wed, 8 Nov 2017 16:35:24 +0530 Subject: [PATCH] Adds social description. - Picks social summary or falls back to meta description --- src/Quintype/Seo/Story.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Quintype/Seo/Story.php b/src/Quintype/Seo/Story.php index f7e0981..e28050f 100644 --- a/src/Quintype/Seo/Story.php +++ b/src/Quintype/Seo/Story.php @@ -53,6 +53,16 @@ protected function getDescription() } } + protected function getSocialDescription() { + if(isset($this->story['summary'])) { + return $this->story['summary']; + } elseif (isset($this->story['seo']['meta-description'])&&($this->story['seo']['meta-description']!="")) { + return $this->story['seo']['meta-description']; + } else { + return ''; + } + } + protected function getSectionName() { if (isset($this->story['sections'][0]['name'])) { @@ -78,7 +88,7 @@ private function getOgAttributes() 'type' => 'article', 'url' => $this->getCanonicalUrl(), 'site-name' => trim($this->config['title']), - 'description' => trim($this->getDescription()), + 'description' => trim($this->getSocialDescription()), 'image' => $this->getHeroImageUrl(), ]; @@ -100,7 +110,7 @@ private function getTwitterAttributes() { $attributes = [ 'title' => trim($this->getTitle()), - 'description' => trim($this->getDescription()), + 'description' => trim($this->getSocialDescription()), 'card' => 'summary_large_image', 'site' => $this->getTwitterSite(), 'creator' => $this->getTwitterCreator(),