From c9e303463c336d4417725fc9b2178e8681fd18a3 Mon Sep 17 00:00:00 2001 From: ajaymenon0 Date: Fri, 10 Nov 2017 10:45:59 +0530 Subject: [PATCH] Added OG description fallback --- src/Quintype/Seo/Section.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Quintype/Seo/Section.php b/src/Quintype/Seo/Section.php index f8c4640..9441a36 100644 --- a/src/Quintype/Seo/Section.php +++ b/src/Quintype/Seo/Section.php @@ -26,7 +26,14 @@ function prepareTags() { ] ]; } else { - return ['title' => trim($this->getPageTitle())]; + return [ + 'title' => trim($this->getPageTitle()), + 'description' => trim($this->getDescription()), + 'og' => [ + 'title' => trim($this->getPageTitle()), + 'description' => trim($this->getDescription()) + ] + ]; } } @@ -41,4 +48,16 @@ protected function getPageTitle(){ return $this->sectionName . $this->titleTextToAppend; } } + + protected function getDescription() { + if(isset($this->seoMetadata['description'])){ + if($this->seoMetadata['description']==''){ + return $this->sectionName . $this->titleTextToAppend; + }else{ + return $this->seoMetadata['description']; + } + } else { + return $this->sectionName . $this->titleTextToAppend; + } + } }