{% assign prefix = site.attrs.base_url %} {% assign normalized_path = page.url | replace: ".html","" | remove_first: prefix %} {% if page.toc != false %} {% for guide in site.data.toc %} {% if guide.items %} {% assign guide_class = 'collapsed' %} {% capture submenu %} {% for chapter in guide.items %} {% assign chapter_class = 'collapsed' %} {% assign normalized_chapter_url = chapter.url | prepend: "/" %} {% if normalized_path == normalized_chapter_url %} {% assign guide_class = 'expanded' %} {% assign chapter_class = 'expanded' %} {% endif %} {% if chapter.items %} {% assign matching_items_count = chapter.items | where: 'url', normalized_path | size %} {% if matching_items_count != 0 %} {% assign chapter_class = 'expanded parent' %} {% endif %} {{chapter.title}} {% for subpage in chapter.items %} {% assign normalized_subpage_url = subpage.url | prepend: "/" %} {% if normalized_path == normalized_subpage_url %} {% assign guide_class = 'expanded' %} {% assign chapter_class = 'expanded' %} {% endif %} {{subpage.title}} {% endfor %} {% else %} {{chapter.title}} {% endif %} {% endfor %} {% endcapture %} {{guide.title}} {{ submenu }} {% else %} {{guide.title}} {% endif %} {% endfor %}