make current_path optional to support 404 template

This commit is contained in:
2026-03-04 18:09:26 +08:00
parent d0833039a6
commit 4180df4389

View File

@@ -42,10 +42,10 @@
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="shortcut icon" type="image/x-icon">
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="icon" type="image/x-icon">
<link href="https://m-labs.hk{{ current_path | safe }}" rel="canonical" >
<link href="https://m-labs.hk{{ current_path | safe }}" rel="alternate" hreflang="x-default" >
<link href="https://m-labs.ph{{ current_path | safe }}" rel="alternate" hreflang="en-ph" >
<link href="https://m-labs-intl.com{{ current_path | safe }}" rel="alternate" hreflang="en-us" >
<link href="https://m-labs.hk{{ current_path | default(value="/") | safe }}" rel="canonical" >
<link href="https://m-labs.hk{{ current_path | default(value="/") | safe }}" rel="alternate" hreflang="x-default" >
<link href="https://m-labs.ph{{ current_path | default(value="/") | safe }}" rel="alternate" hreflang="en-ph" >
<link href="https://m-labs-intl.com{{ current_path | default(value="/") | safe }}" rel="alternate" hreflang="en-us" >
{% block links %}{% endblock %}
@@ -94,22 +94,22 @@
{% for section in section.subsections %}
{% set subsection = get_section(path=section) %}
{% set root_current_path = current_path | trim_start_matches(pat='/') | split(pat='/') | first %}
{% set root_current_path = current_path | default(value="/") | trim_start_matches(pat='/') | split(pat='/') | first %}
{% set root_section_path = subsection.path | trim_start_matches(pat='/') | split(pat='/') | first %}
{% if subsection.pages|length > 0 and subsection.extra.in_topbar %}
<li class="nav-item ms-0 ms-md-4 dropdown {% if root_current_path == root_section_path %}active{% endif %}">
<a class="nav-link dropdown-toggle {% if current_path == subsection.path %}active{% endif %}" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a class="nav-link dropdown-toggle {% if current_path is defined and current_path == subsection.path %}active{% endif %}" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ subsection.title }}
</a>
<div class="dropdown-menu shadow-none shadow-lg text-start text-lg-start" aria-labelledby="navbarDropdown">
{% for tmp_page in subsection.pages %}
<a class="dropdown-item pt-2 pb-2 {% if current_path == tmp_page.path %}active{% endif %}" href="{{ tmp_page.permalink | safe }}" itemprop="url">{{ tmp_page.title }}</a>
<a class="dropdown-item pt-2 pb-2 {% if current_path is defined and current_path == tmp_page.path %}active{% endif %}" href="{{ tmp_page.permalink | safe }}" itemprop="url">{{ tmp_page.title }}</a>
{% endfor %}
{% if subsection.extra.place_order %}
<a class="dropdown-item pt-2 pb-2 mx-4 mt-2 mb-2 mt-sm-3 mb-sm-3 w-auto btn btn-primary btn-inversed {% if current_path == "order/_index.md" %}active{% endif %} rounded-1" href="{{
<a class="dropdown-item pt-2 pb-2 mx-4 mt-2 mb-2 mt-sm-3 mb-sm-3 w-auto btn btn-primary btn-inversed {% if current_path is defined and current_path == "order/_index.md" %}active{% endif %} rounded-1" href="{{
get_url(path="@/order/_index.md") | safe }}" itemprop="url">
<center>{{ "Order hardware" }}</center>
</a>
@@ -120,7 +120,7 @@
{% elif subsection.extra.in_topbar %}
<li class="nav-item ms-0 ms-md-4 {% if current_path == subsection.path %}active{% endif %}">
<li class="nav-item ms-0 ms-md-4 {% if current_path is defined and current_path == subsection.path %}active{% endif %}">
<a class="nav-link" href="{{ subsection.permalink | safe }}">{{ subsection.title }}</a>
</li>