|
| 1 | +{%- comment -%} |
| 2 | + Include as: {%- include components/children_nav-sitemap.html -%} |
| 3 | + Depends on: page, site, nav_breadcrumbs. |
| 4 | + Results in: HTML for the children-navigation component. |
| 5 | + Includes: components/nav/sorted.html. |
| 6 | + Overwrites: |
| 7 | + nav_ancestor_links, nav_top_node_titles, nav_child_candidates, nav_children, |
| 8 | + nav_child, nav_child_ok, nav_child_ancestor, nav_sorted. |
| 9 | +{%- endcomment -%} |
| 10 | + |
| 11 | +{%- comment -%} |
| 12 | + Whether a page has any children is checked efficiently by inspecting the cached |
| 13 | + site_nav. If the page has no children, nav_children is set to an empty array; |
| 14 | + otherwise nav_children is left unset. (The site_nav is rendered the first time |
| 15 | + it is included, and that may overwrite various variables.) |
| 16 | +{%- endcomment -%} |
| 17 | + |
| 18 | + {%- if page.has_children == false -%} |
| 19 | + {%- assign nav_children = "" | split: "" -%} |
| 20 | + {%- else -%} |
| 21 | + |
| 22 | + {%- capture site_nav -%} |
| 23 | + {%- include_cached components/site_nav.html all=true -%} |
| 24 | + {%- endcapture -%} |
| 25 | + |
| 26 | + {%- assign nav_children = nil -%} |
| 27 | + |
| 28 | + {%- capture nav_list_link -%} |
| 29 | + <a href="{{ page.url | relative_url }}"> |
| 30 | + {%- endcapture -%} |
| 31 | + |
| 32 | + {%- capture nav_list_simple -%} |
| 33 | + <ul> |
| 34 | + {%- endcapture -%} |
| 35 | + |
| 36 | + |
| 37 | +{%- endif -%} |
| 38 | + |
| 39 | +{%- unless nav_children -%} |
| 40 | + |
| 41 | + {%- comment -%} |
| 42 | + The layout is assumed to include components/breadcrumbs.html before this file, |
| 43 | + otherwise it needs to be included here. |
| 44 | + {%- endcomment -%} |
| 45 | + |
| 46 | + |
| 47 | + {%- assign nav_parenthood = site[page.collection] | default: site.html_pages |
| 48 | + | where_exp: "item", "item.title != nil" | group_by: "parent" -%} |
| 49 | + |
| 50 | + {%- assign nav_top_nodes = nav_parenthood |
| 51 | + | where_exp: "item", "item.name == ''" | map: "items" | first -%} |
| 52 | + |
| 53 | + {% assign nav_top_node_titles = nav_top_nodes | map: "title" -%} |
| 54 | + |
| 55 | + {%- include components/nav/children.html node=page ancestors=nav_ancestors all=true -%} |
| 56 | + |
| 57 | +{%- endunless -%} |
| 58 | + |
| 59 | +{%- if nav_children.size >= 1 -%} |
| 60 | + |
| 61 | + {%- if page.child_nav_order == 'desc' or page.child_nav_order == 'reversed' -%} |
| 62 | + {%- assign nav_children = nav_children | reverse -%} |
| 63 | + {%- endif -%} |
| 64 | + |
| 65 | +<nav aria-label="Related content" class="toc"> |
| 66 | + |
| 67 | +<h2 class="no_toc" id="table-of-contents">Pages in: {{ page.title }}</h2> |
| 68 | +<ul role="list"> |
| 69 | + {% for nav_child in nav_children %} |
| 70 | + <li> |
| 71 | + <h3> |
| 72 | + <a href="{{ nav_child.url | relative_url }}">{{ nav_child.title }}</a> |
| 73 | + </h3> |
| 74 | + <p>{{ nav_child.description }}</p> |
| 75 | + </li> |
| 76 | + {% endfor %} |
| 77 | + |
| 78 | +</ul> |
| 79 | + |
| 80 | + {% if page.parent %} |
| 81 | + {% assign introPage = site.pages | where: "title", page.parent | first %} |
| 82 | + |
| 83 | + <p> |
| 84 | + <span aria-hidden="true">←</span> <a href="{{ introPage.url | relative_url }}">Back to: {{ introPage.title }}</a> |
| 85 | + </p> |
| 86 | + |
| 87 | + {% else %} |
| 88 | + |
| 89 | + <p> |
| 90 | + <span aria-hidden="true">←</span> <a href="{{ site.url | relative_url }}">Back to: Home</a> |
| 91 | + </p> |
| 92 | + |
| 93 | + {% endif %} |
| 94 | + |
| 95 | +</nav> |
| 96 | + |
| 97 | +{% else %} |
| 98 | + |
| 99 | + {% include components/siblings.html %} |
| 100 | + |
| 101 | +{%- endif -%} |
0 commit comments