mirror of
https://github.com/pawroman/zola-theme-terminimal.git
synced 2025-01-09 20:21:06 +01:00
Fix relative URL handling
This commit is contained in:
parent
70a4927088
commit
7653cfed54
|
@ -204,13 +204,14 @@ of your `config.toml`:
|
||||||
# menu is enabled by adding menu_items (optional)
|
# menu is enabled by adding menu_items (optional)
|
||||||
menu_items = [
|
menu_items = [
|
||||||
# each of these is optional, name and url are required
|
# each of these is optional, name and url are required
|
||||||
{name = "blog", url = "/"},
|
# $BASE_URL is going to be substituted by base_url from configuration
|
||||||
|
{name = "blog", url = "$BASE_URL"},
|
||||||
|
|
||||||
# tags should only be enabled if you have "tags" taxonomy
|
# tags should only be enabled if you have "tags" taxonomy
|
||||||
# see documentation below for more details
|
# see documentation below for more details
|
||||||
{name = "tags", url = "/tags"},
|
{name = "tags", url = "$BASE_URL/tags"},
|
||||||
{name = "archive", url = "/archive"},
|
{name = "archive", url = "$BASE_URL/archive"},
|
||||||
{name = "about me", url = "/about"},
|
{name = "about me", url = "$BASE_URL/about"},
|
||||||
|
|
||||||
# set newtab to true to make the link open in new tab
|
# set newtab to true to make the link open in new tab
|
||||||
{name = "github", url = "url-to-your-github", newtab = true},
|
{name = "github", url = "url-to-your-github", newtab = true},
|
||||||
|
|
10
config.toml
10
config.toml
|
@ -1,3 +1,4 @@
|
||||||
|
# Be sure to change these!
|
||||||
base_url = "https://pawroman.github.io/zola-theme-terminimal"
|
base_url = "https://pawroman.github.io/zola-theme-terminimal"
|
||||||
title = "Zola Terminimal theme"
|
title = "Zola Terminimal theme"
|
||||||
|
|
||||||
|
@ -43,13 +44,14 @@ logo_text = "Terminimal theme"
|
||||||
# menu is enabled by adding menu_items (optional)
|
# menu is enabled by adding menu_items (optional)
|
||||||
menu_items = [
|
menu_items = [
|
||||||
# each of these is optional, name and url are required
|
# each of these is optional, name and url are required
|
||||||
{name = "blog", url = "/"},
|
# $BASE_URL is going to be substituted by base_url from configuration
|
||||||
|
{name = "blog", url = "$BASE_URL"},
|
||||||
|
|
||||||
# tags should only be enabled if you have "tags" taxonomy
|
# tags should only be enabled if you have "tags" taxonomy
|
||||||
# see documentation below for more details
|
# see documentation below for more details
|
||||||
{name = "tags", url = "/tags"},
|
{name = "tags", url = "$BASE_URL/tags"},
|
||||||
{name = "archive", url = "/archive"},
|
{name = "archive", url = "$BASE_URL/archive"},
|
||||||
{name = "about me", url = "/about"},
|
{name = "about me", url = "$BASE_URL/about"},
|
||||||
|
|
||||||
# set newtab to true to make the link open in new tab
|
# set newtab to true to make the link open in new tab
|
||||||
{name = "github", url = "https://github.com/pawroman/zola-theme-terminimal", newtab = true},
|
{name = "github", url = "https://github.com/pawroman/zola-theme-terminimal", newtab = true},
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
<nav class="menu">
|
<nav class="menu">
|
||||||
<ul class="menu__inner">
|
<ul class="menu__inner">
|
||||||
{%- for item in menu_items %}
|
{%- for item in menu_items %}
|
||||||
{%- set current = item.url == current_path
|
{%- set rel_item_url = item.url | replace(from="$BASE_URL", to="") -%}
|
||||||
or item.url == "/" ~ current_path
|
{%- set current = rel_item_url == current_path
|
||||||
or item.url ~ "/" == "/" ~ current_path
|
or rel_item_url == "/" ~ current_path
|
||||||
|
or rel_item_url ~ "/" == "/" ~ current_path
|
||||||
|
or rel_item_url == "" and current_path == "/"
|
||||||
-%}
|
-%}
|
||||||
{%- if current %}
|
{%- if current %}
|
||||||
{%- set_global current_item = item -%}
|
{%- set_global current_item = item -%}
|
||||||
|
@ -18,9 +20,9 @@
|
||||||
{%- set blog_post = not current_item and item.url == "/" -%}
|
{%- set blog_post = not current_item and item.url == "/" -%}
|
||||||
<li {%- if current_item and item == current_item or blog_post %} class="active" {%- endif %}>
|
<li {%- if current_item and item == current_item or blog_post %} class="active" {%- endif %}>
|
||||||
{%- if item.newtab -%}
|
{%- if item.newtab -%}
|
||||||
<a href="{{ item.url | safe }}" target="_blank" rel="noopener noreferrer">{{ item.name | safe }}</a>
|
<a href="{{ item.url | replace(from="$BASE_URL", to=config.base_url) | safe }}" target="_blank" rel="noopener noreferrer">{{ item.name | safe }}</a>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<a href="{{ item.url | safe }}">{{ item.name | safe }}</a>
|
<a href="{{ item.url | replace(from="$BASE_URL", to=config.base_url) | safe }}">{{ item.name | safe }}</a>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</li>
|
</li>
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
|
Loading…
Reference in a new issue