File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ def primarynavmobile(context):
34
34
35
35
@register .simple_tag (name = "get_top_level_parent_page" , takes_context = True )
36
36
def get_top_level_parent_page (context ):
37
+ # Exit immediately if there is there's no data available.
38
+ if "page" not in context or "settings" not in context :
39
+ return None
40
+
37
41
# Get all page links from the primary nav.
38
42
primary_nav = [
39
43
block .value ["page" ]
Original file line number Diff line number Diff line change 20
20
</ nav >
21
21
22
22
{# Primary mobile menu toggle #}
23
- < button class ="header__primary-menu-toggle " data-primary-mobile-menu-toggle aria-haspopup ="true " aria-expanded ="false " aria-label ="Mobile menu toggle ">
24
- Home
23
+ {% get_top_level_parent_page as parent_page %} {# Get the top-level parent page #}
24
+ {% firstof parent_page.title "Home" as parent_title %} {# Get the parent's title, or Home if no parent #}
25
+ < button
26
+ aria-expanded ="false "
27
+ aria-haspopup ="true "
28
+ aria-label ="Mobile menu toggle - currently viewing '{{ parent_title }}' or pages below it "
29
+ class ="header__primary-menu-toggle "
30
+ data-primary-mobile-menu-toggle
31
+ >
32
+ {{ parent_title }}
25
33
{% include "patterns/atoms/icons/icon.html" with name="chevron" classname="header__primary-menu-toggle-icon" %}
26
34
</ button >
27
35
You can’t perform that action at this time.
0 commit comments