Highlight active page in sidebar menu

This commit is contained in:
timvisee 2019-07-01 22:04:04 +02:00
parent 9de4c2a00a
commit fe02300eec
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
3 changed files with 16 additions and 11 deletions

View File

@ -23,9 +23,9 @@ author = "Tim Visée"
zenn_title = "Tim Visee"
zenn_menu = [
{url = "$BASE_URL", name = "Home"},
{url = "$BASE_URL/projects", name = "Projects"},
{url = "$BASE_URL/blog", name = "Blog"},
{url = "$BASE_URL/about", name = "About"},
{url = "$BASE_URL/", name = "Home"},
{url = "$BASE_URL/projects/", name = "Projects"},
{url = "$BASE_URL/blog/", name = "Blog"},
{url = "$BASE_URL/about/", name = "About"},
]
zenn_source = "https://gitlab.com/timvisee/blog.timvisee.com/"

View File

@ -263,7 +263,7 @@ sidebar > section {
padding: 0 1.5rem;
font-family: $font-title;
&:hover, &.active {
&.active {
background-color: rgba($link-color, 0.1);
}
&:active {

View File

@ -89,8 +89,8 @@
{% for item in config.extra.zenn_menu %}
<li>
<a itemprop="url"
class="{% if item.url | replace(from="$BASE_URL", to=config.base_url) == current_url %}active{% endif %}"
href="{{ item.url | safe | replace(from="$BASE_URL", to=config.base_url) }}">
class="{% if item.url | replace(from="$BASE_URL", to=config.base_url) == current_url %}active{% endif %}"
href="{{ item.url | safe | replace(from="$BASE_URL", to=config.base_url) }}">
<span itemprop="name">{{ item.name }}</span>
</a>
</li>
@ -107,10 +107,12 @@
<h1><a href="/categories">Categories</a></h1>
<nav itemscope itemtype="http://schema.org/SiteNavigationElement">
<ul>
{% for catgegory in categories.items %}
{% for category in categories.items %}
<li>
<a itemprop="url" href="{{ catgegory.permalink | safe }}">
<span itemprop="name">{{ catgegory.name | title }}</span>
<a itemprop="url"
class="{% if category.permalink | replace(from="$BASE_URL", to=config.base_url) == current_url %}active{% endif %}"
href="{{ category.permalink | safe }}">
<span itemprop="name">{{ category.name | title }}</span>
</a>
</li>
{% endfor %}
@ -126,7 +128,10 @@
<h1><a href="/tags">Tags</a></h1>
<div class="tags">
{% for tag in tags.items %}
<a href="{{ tag.permalink | safe }}" class="tag">{{ tag.name }}</a>
<a href="{{ tag.permalink | safe }}"
class="tag {% if tag.permalink | replace(from="$BASE_URL", to=config.base_url) == current_url %}active{% endif %}">
{{ tag.name }}
</a>
{% endfor %}
</div>
</section>