Add active menu link styling
This commit is contained in:
parent
1e504a944f
commit
c6ee7f805e
|
@ -1,2 +1,16 @@
|
||||||
name: Oliver Davies
|
name: Oliver Davies
|
||||||
locale: en-GB
|
locale: en-GB
|
||||||
|
|
||||||
|
menus:
|
||||||
|
main:
|
||||||
|
- title: About
|
||||||
|
href: /
|
||||||
|
is_active: '^//$'
|
||||||
|
|
||||||
|
- title: Blog
|
||||||
|
href: /blog
|
||||||
|
is_active: '^/blog/?'
|
||||||
|
|
||||||
|
- title: Talks
|
||||||
|
href: /talks
|
||||||
|
is_active: '^/talks/?'
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<nav class="flex flex-col items-center mt-4 md:mt-0 md:flex-row md:space-x-4">
|
<nav class="flex flex-col items-center mt-4 md:mt-0 md:flex-row md:space-x-4">
|
||||||
<a class="text-black" href="/">About</a>
|
{% for item in site.menus.main %}
|
||||||
<a class="text-black" href="/blog">Blog</a>
|
{% set is_active = page.url matches '#' ~ item.is_active ~ '#' %}
|
||||||
<a class="text-black" href="/talks">Talks</a>
|
<a class="text-black border-b-3 py-2 {{ is_active ? 'border-blue-700' : 'border-transparent' }}" href="{{ item.href }}">{{ item.title }}</a>
|
||||||
|
{% endfor %}
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue