Files
expressjs.com/_includes/bottom-navigation.html
shubham oulkar edf3ba4285 feat: bottom page navigation component (#2085)
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2025-11-07 18:02:57 -05:00

46 lines
1.3 KiB
HTML

{% assign current_menu = page.menu %}
{% assign current_lang = page.lang %}
{% if current_menu and current_lang %}
{% assign all_pages_in_menu = site.pages | where: "menu", current_menu %}
{% assign lang_specific_pages = all_pages_in_menu | where: "lang", current_lang %}
{% assign sorted_pages = lang_specific_pages | sort: "order" %}
{% for doc in sorted_pages %}
{% if doc.path == page.path %}
{% assign current_index = forloop.index0 %}
{% break %}
{% endif %}
{% endfor %}
{% if current_index != nil %}
{% assign prev_index = current_index | minus: 1 %}
{% if prev_index >= 0 %}
{% assign prev_page = sorted_pages[prev_index] %}
{% endif %}
{% assign next_index = current_index | plus: 1 %}
{% if next_index < sorted_pages.size %}
{% assign next_page = sorted_pages[next_index] %}
{% endif %}
{% endif %}
{% if prev_page or next_page %}
<nav class="bottom-navigation" aria-label="Pagination">
{% if prev_page %}
<a href="{{ prev_page.url | relative_url }}" class="bottom-nav-prev">
Previous: {{ prev_page.title }}
</a>
{% endif %}
{% if next_page %}
<a href="{{ next_page.url | relative_url }}" class="bottom-nav-next">
Next: {{ next_page.title }}
</a>
{% endif %}
</nav>
{% endif %}
{% endif %}