Skip to content

Commit

Permalink
Merge branch 'master' of github.com:quintype/quintype-seo-php
Browse files Browse the repository at this point in the history
  • Loading branch information
anagh-p committed Dec 19, 2017
2 parents 659ddc8 + 92b6ada commit da23dd9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
21 changes: 20 additions & 1 deletion src/Quintype/Seo/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
]
];
}
}

Expand All @@ -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;
}
}
}
15 changes: 12 additions & 3 deletions src/Quintype/Seo/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function prepareTags()
'description' => trim($this->getDescription()),
'keywords' => trim($this->getKeywords(["stories" => $this->story])),
'news_keywords' => trim($this->getKeywords(["stories" => $this->story])),
'section' => trim($this->getSectionName()),
'image_src' => $this->getHeroImageUrl(),
'og' => $this->getOgAttributes(),
'twitter' => $this->getTwitterAttributes(),
Expand Down Expand Up @@ -52,6 +51,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'])) {
Expand All @@ -77,7 +86,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(),
];

Expand All @@ -99,7 +108,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(),
Expand Down

0 comments on commit da23dd9

Please sign in to comment.