Skip to content

Commit 96a178f

Browse files
committed
Add option to show login/logout url in navbar
1 parent 9b75fbc commit 96a178f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

grav-coder.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ dropdown:
33
enabled: true
44
navbar:
55
title: Grav Coder
6+
auth_link:
7+
enabled: false
8+
login_slug: login
9+
login_label: Login
610
footer:
711
copyright: Grav Coder
812
post:
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
<ul class="nav navbar-nav navbar-right ">
22
{% for page in pages.children.visible %}
3-
{% set active_page = (page.active or page.activeChild) ? 'active' : '' %}
3+
{% set active_page = (page.active or page.activeChild) ? 'active' : '' %}
44
<li>
55
<a href="{{ page.url }}" class="{{ active_page }}">
66
{{ page.menu }}
77
</a>
88
</li>
99
{% endfor %}
10+
11+
{% if theme_config.navbar.auth_link.enabled and config.plugins.login.enabled %}
12+
{% if grav.user.authenticated %}
13+
<li>
14+
<a href="{{ url(uri.addNonce((uri.path)|trim('/') ~ '/task' ~ config.system.param_sep ~ 'login.logout', 'logout-form', 'logout-nonce'))|e }}">
15+
{{ grav.user.fullname ?: grav.user.username }}, Logout
16+
</a>
17+
</li>
18+
{% else %}
19+
{% set active_page = (page.slug == (theme_config.navbar.auth_link.login_slug | default('login'))) ? 'active' : '' %}
20+
<li>
21+
<a href="/{{ theme_config.navbar.auth_link.login_slug }}" class="{{ active_page }}">
22+
{{ theme_config.navbar.auth_link.login_label | default('Login') }}
23+
</a>
24+
</li>
25+
{% endif %}
26+
{% endif %}
1027
</ul>
1128

0 commit comments

Comments
 (0)