diff --git a/.gitignore b/.gitignore index d5ec451..6349009 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ tags .php_cs.cache .idea + diff --git a/src/Models/Metadata.php b/src/Models/Metadata.php index c5653cd..4e49c9d 100644 --- a/src/Models/Metadata.php +++ b/src/Models/Metadata.php @@ -57,18 +57,21 @@ public function field($column) } } - protected function getFallbackValue($column) { - if( !array_key_exists($column, $this->fallbacks()) ) { - return; + protected function getFallbackValue($column) + { + if (!array_key_exists($column, $this->fallbacks())) { + return false; } $fallback = $this->fallbacks()[$column]; - if($column == 'title' || $column == 'og_title') { + + if ($column == 'title' || $column == 'og_title') { $site_title = app(SettingRepository::class)->byKey('site_title', 'seo'); - return strip_tags($this->meta_describable->$fallback) . ($site_title ? ' - '. $site_title : ''); + return strip_tags($this->meta_describable->$fallback).($site_title ? ' - '.$site_title : ''); } else { return strip_tags($this->meta_describable->$fallback); } + } protected function fallbacks() { diff --git a/src/Traits/SetsMetadata.php b/src/Traits/SetsMetadata.php index 730b871..1071e4c 100644 --- a/src/Traits/SetsMetadata.php +++ b/src/Traits/SetsMetadata.php @@ -11,10 +11,15 @@ public function setMetadata(Model $describable, array $metadata=[]) { $request = request(); SEOTools::setTitle($metadata->field('title')); - SEOTools::setDescription($metadata->field('description')); + if( $metadata->field('description') ) { + SEOTools::setDescription($metadata->field('description')); + } SEOTools::opengraph()->setTitle($metadata->field('og_title')); - SEOTools::opengraph()->setDescription($metadata->field('og_description')); + + if($metadata->field('og_description')) { + SEOTools::opengraph()->setDescription($metadata->field('og_description')); + } SEOTools::opengraph()->addProperty('type', $metadata->field('og_type')); diff --git a/src/config/metadata.php b/src/config/metadata.php index 50b2aeb..d60d164 100644 --- a/src/config/metadata.php +++ b/src/config/metadata.php @@ -4,9 +4,9 @@ 'fallbacks' => [ 'title' => 'title', - 'description' => '', + 'description' => false, 'og_title' => 'title', - 'og_description' => '', + 'og_description' => false, 'og_type' => 'metadataDefaultOgType', 'card_type' => 'metadataDefaultCardType', ],