diff --git a/app/controllers/BlogController.php b/app/controllers/BlogController.php index a59e650..fc0d0b4 100644 --- a/app/controllers/BlogController.php +++ b/app/controllers/BlogController.php @@ -54,9 +54,20 @@ class BlogController extends PageController { return "{$date}"; }; - $this->router->service()->tags = function (string $tags): array { + $this->router->service()->tags = function (string $tags): string { + $result = ""; + // Remove empty elements via array_filter() - return array_filter(explode(':', $tags)); + $splitTags = array_filter(explode(':', $tags), function ($tag) { + return !empty(trim($tag)); + }); + + foreach ($splitTags as $key => $tag) { + $result .= $tag; + $result .= (($key === array_key_last($splitTags)) ? '' : ', '); + } + + return $result; }; } diff --git a/app/views/partials/blog-posts.php b/app/views/partials/blog-posts.php index 9654423..97ca0d0 100644 --- a/app/views/partials/blog-posts.php +++ b/app/views/partials/blog-posts.php @@ -15,13 +15,7 @@
- - tags: - tags)($post['tag']); ?> - $tag) { ?> - = $tag . (($key === array_key_last($tags)) ? '' : ', '); ?> - - + tags: = ($this->tags)($post['tag']); ?>