Skip to content

Commit

Permalink
fix: Highlight multiple categories of the post
Browse files Browse the repository at this point in the history
When a post belongs to more than one category, then those categories will be highlighted

Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
liaocp666 committed Aug 15, 2023
1 parent 1df8e6a commit f8dbc1c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions core/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ public function execute()
*/
function isActiveMenu($self, $slug): string
{
$category = "";
$activeMenuClass = "jasmine-primary-bg shadow-lg !text-white";

if ($self->is("category")) {
$category = $self->getArchiveSlug();
} else if ($self->is("post")) {
$category = $self->category;
if ($self->is("category") && $self->getArchiveSlug() === $slug) {
return $activeMenuClass;
}

if ($category === $slug) {
return "jasmine-primary-bg shadow-lg !text-white";
if ($self->is("post") && in_array($slug, array_column($self->categories, 'slug'))) {
return $activeMenuClass;
}

return "";
}
}

0 comments on commit f8dbc1c

Please sign in to comment.