From 0d5a1fd4ec0d5a72ccc5e97a509b7a91c1272ee0 Mon Sep 17 00:00:00 2001 From: COil Date: Sat, 21 Dec 2024 21:37:17 +0100 Subject: [PATCH] chore: better menu --- src/Twig/Extension/RoutingExtension.php | 6 ++++++ templates/base.html.twig | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Twig/Extension/RoutingExtension.php b/src/Twig/Extension/RoutingExtension.php index d54d2c0..cf4a9e1 100644 --- a/src/Twig/Extension/RoutingExtension.php +++ b/src/Twig/Extension/RoutingExtension.php @@ -32,6 +32,7 @@ public function getFunctions(): array return [ new TwigFunction('ctrl_fqcn', $this->getControllerFqcn(...)), new TwigFunction('attr_if', $this->getAttributeIf(...)), + new TwigFunction('aria_current_page_if', $this->getAriaCurrentPageIf(...)), ]; } @@ -85,4 +86,9 @@ public function getAttributeIf(bool $condition, string $attribute, string $value return \sprintf(' %s="%s"', $attribute, $value); } + + public function getAriaCurrentPageIf(bool $condition): string + { + return $this->getAttributeIf($condition, 'aria-current', 'page'); + } } diff --git a/templates/base.html.twig b/templates/base.html.twig index 1e54a97..572dadc 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -47,11 +47,11 @@ Menu