Move menu items from settings into partial

Better ability to set active and enabled values
This commit is contained in:
Oliver Davies 2019-05-03 19:26:36 +01:00
parent 2c67e11bf7
commit 4030b0ed14
3 changed files with 37 additions and 31 deletions

View file

@ -12,22 +12,6 @@ eventbrite:
papercall: papercall:
url: https://www.papercall.io/drupalcamp-bristol-2019 url: https://www.papercall.io/drupalcamp-bristol-2019
main_menu:
- title: Tickets
url: '%eventbrite.url%'
pattern: ~
enabled: '%tickets.available%'
- title: Submit a session
url: '%papercall.url%'
pattern: ~
enabled: '%cfp.open%'
- title: Sponsor us
url: /sponsor-us
pattern: /^\/sponsor-us\/?/
enabled: true
tickets: tickets:
available: true available: true
url: '%eventbrite.url%' url: '%eventbrite.url%'

View file

@ -6,20 +6,6 @@
</a> </a>
</div> </div>
<nav role="navigation" aria-labelledby="block-dcb2017-main-menu-menu" id="block-dcb2017-main-menu" class="block block-menu navigation menu--main"> {% include 'nav' %}
<h2 class="visually-hidden" id="block-dcb2017-main-menu-menu">Main navigation</h2>
<ul class="tw-list-reset tw-flex tw-flex-wrap tw-justify-center tw--ml-8">
{% for item in site.main_menu if item.enabled == true %}
<li class="tw-mb-2 tw-mx-4 md:tw-m-0 md:tw-ml-8">
<a
class="tw-uppercase tw-no-underline hocus:tw-text-green-600 {{ item.pattern and page.url matches item.pattern ? 'tw-text-green-600' : 'tw-text-black' }}"
href="{{ item.url }}"
>
{{ item.title }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</div> </div>
</header> </header>

View file

@ -0,0 +1,36 @@
{% set links = [
{
title: 'Tickets',
href: site['tickets']['url'],
active: false,
enabled: site['tickets']['available'],
},
{
title: 'Submit a session',
href: site['cfp']['url'],
active: false,
enabled: site['cfp']['open'],
},
{
title: 'Sponsor us',
href: '/sponsor-us',
active: page.url == '/sponsor-us',
enabled: true,
}
] %}
<nav role="navigation" aria-labelledby="block-dcb2017-main-menu-menu" id="block-dcb2017-main-menu" class="block block-menu navigation menu--main">
<h2 class="visually-hidden" id="block-dcb2017-main-menu-menu">Main navigation</h2>
<ul class="tw-list-reset tw-flex tw-flex-wrap tw-justify-center tw--ml-8">
{% for link in links if link.enabled %}
<li class="tw-mb-2 tw-mx-4 md:tw-m-0 md:tw-ml-8">
<a
class="tw-uppercase tw-no-underline hocus:tw-text-green-600 {{ link.active ? 'tw-text-green-600' : 'tw-text-black' }}"
href="{{ link.href|raw }}"
>
{{ link.title }}
</a>
</li>
{% endfor %}
</ul>
</nav>