Back to Opennhp

Site Nav

docs/_includes/components/site_nav.html

0.7.3856 B
Original Source

{%- comment -%} Override of jtd's site_nav.html. Splits the nav by language so that visitors on /zh-cn/ pages see the Chinese sidebar, and everyone else sees the English one. The filter is based on page URLs — pages whose URL contains /zh-cn/ are Chinese, everything else is English. {%- endcomment -%} {% assign is_zh = false %} {% if page.url contains '/zh-cn/' %}{% assign is_zh = true %}{% endif %} {%- comment -%} Build lang_pages manually — Liquid's where_exp struggles with negated contains expressions, so we loop and push explicitly. {%- endcomment -%} {% assign lang_pages = "" | split: "" %} {% for p in site.html_pages %} {% assign p_is_zh = false %} {% if p.url contains '/zh-cn/' %}{% assign p_is_zh = true %}{% endif %} {% if p_is_zh == is_zh %} {% assign lang_pages = lang_pages | push: p %} {% endif %} {% endfor %}