compute the menu recursively; put it between title and content
[web.git] / _includes / menu-level.html
diff --git a/_includes/menu-level.html b/_includes/menu-level.html
new file mode 100644 (file)
index 0000000..ae29931
--- /dev/null
@@ -0,0 +1,12 @@
+<ul>{% for item in include.menu %}<!--
+    {% comment %} We compute the full URL of this item, and truncate canonicalurl so that length so we can test whether it starts with it {% endcomment %}
+    {% assign cururl = item.url | prepend: include.base %}
+    {% assign isparent_search = canonicalurl | truncate: cururl.size, '' %}
+    {% capture class %}{% if cururl == canonicalurl %}current{% elsif include.above != true %}child{% elsif isparent_search == cururl %}parent{% else %}sibling{% endif %}{% endcapture %}
+    {% comment %} Now we can output the item and it substructure {% endcomment %}
+    --><li class="{{ class }}"><a href="{{ item.url | prepend: include.base }}">{{ item.title }}</a></li><!--
+    {% if item.structure and (class == "current" or class == "parent") %}
+        {% if cururl == canonicalurl %}{% assign above = false %}{% else %}{% assign above = true %}{% endif %}
+        -->{% include menu-level.html menu=item.structure base=cururl above=above %}<!--
+    {% endif %}
+-->{% endfor %}</ul>