diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index 6f746e64..c637ed47 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -235,7 +235,10 @@ public function listPostsByCategoryAction(Category $category = null): void $this->view->assign('posts', $posts); $this->view->assign('category', $category); MetaTagService::set(MetaTagService::META_TITLE, (string) $category->getTitle()); - MetaTagService::set(MetaTagService::META_DESCRIPTION, (string) $category->getDescription()); + + if (!empty($categoryDescription = (string) $category->getDescription())) { + MetaTagService::set(MetaTagService::META_DESCRIPTION, $categoryDescription); + } } else { $this->view->assign('categories', $this->categoryRepository->findAll()); } @@ -256,7 +259,10 @@ public function listPostsByAuthorAction(Author $author = null): void $this->view->assign('posts', $posts); $this->view->assign('author', $author); MetaTagService::set(MetaTagService::META_TITLE, (string) $author->getName()); - MetaTagService::set(MetaTagService::META_DESCRIPTION, (string) $author->getBio()); + + if (!empty($authorBio = (string) $author->getBio())) { + MetaTagService::set(MetaTagService::META_DESCRIPTION, $authorBio); + } } else { $this->view->assign('authors', $this->authorRepository->findAll()); } @@ -277,7 +283,10 @@ public function listPostsByTagAction(Tag $tag = null): void $this->view->assign('posts', $posts); $this->view->assign('tag', $tag); MetaTagService::set(MetaTagService::META_TITLE, (string) $tag->getTitle()); - MetaTagService::set(MetaTagService::META_DESCRIPTION, (string) $tag->getDescription()); + + if (!empty($tagDescription = (string) $tag->getDescription())) { + MetaTagService::set(MetaTagService::META_DESCRIPTION, $tagDescription); + } } else { $this->view->assign('tags', $this->tagRepository->findAll()); }