|
1 | 1 | {% comment %} |
2 | | -Map grabs the doc sections, giving us an array of arrays. Join, flattens all |
| 2 | +Map grabs the docs sections, giving us an array of arrays. Join, flattens all |
3 | 3 | the items to a comma delimited string. Split turns it into an array again. |
4 | 4 | {% endcomment %} |
5 | | -{% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %} |
| 5 | +{% assign _urls = "" %} |
| 6 | +{% for section in site.data.docs %} |
| 7 | + {% for l1 in section.docs %} |
| 8 | + {% assign l1_url = l1.url | prepend:"/docs/" | append:"/" %} |
| 9 | + {% assign l1_doc = site.docs | where:"url", l1_url | first %} |
| 10 | + {% if l1_doc %} |
| 11 | + {% capture _urls %}{{ _urls }},{{ l1_url }}{% endcapture %} |
| 12 | + {% for l2 in l1.docs %} |
| 13 | + {% assign l2_url = l2.url | prepend:"/docs/" | append:"/" %} |
| 14 | + {% assign l2_doc = site.docs | where:"url", l2_url | first %} |
| 15 | + {% if l2_doc %} |
| 16 | + {% capture _urls %}{{ _urls }},{{ l2_url }}{% endcapture %} |
| 17 | + {% for l3 in l2.docs %} |
| 18 | + {% assign l3_url = l3.url | prepend:"/docs/" | append:"/" %} |
| 19 | + {% assign l3_doc = site.docs | where:"url", l3_url | first %} |
| 20 | + {% if l3_doc %} |
| 21 | + {% capture _urls %}{{ _urls }},{{ l3_url }}{% endcapture %} |
| 22 | + {% endif %} |
| 23 | + {% endfor %} |
| 24 | + {% endif %} |
| 25 | + {% endfor %} |
| 26 | + {% endif %} |
| 27 | + {% endfor %} |
| 28 | +{% endfor %} |
| 29 | +{% assign docs = _urls | remove_first: ',' | split: ',' %} |
6 | 30 |
|
7 | 31 | {% comment %} |
8 | 32 | Because this is built for every page, lets find where we are in the ordered |
9 | 33 | document list by comparing url strings. Then if there's something previous or |
10 | 34 | next, lets build a link to it. |
11 | 35 | {% endcomment %} |
12 | 36 |
|
13 | | -{% for document in docs %} |
14 | | - {% assign document_url = document | prepend:"/docs/" | append:"/" %} |
15 | | - {% if document_url == page.url %} |
| 37 | +{% for doc_url in docs %} |
| 38 | + {% if doc_url == page.url %} |
16 | 39 | <div class="section-nav"> |
17 | 40 | <div class="left align-right"> |
18 | 41 | {% if forloop.first %} |
19 | 42 | <span class="prev disabled">Back</span> |
20 | 43 | {% else %} |
21 | 44 | {% assign prev = forloop.index0 | minus: 1 %} |
22 | | - {% assign prev_url = docs[prev] | prepend:"/docs/" | append:"/" %} |
| 45 | + {% assign prev_url = docs[prev] %} |
23 | 46 | {% assign prev_doc = site.docs | where: "url", prev_url | first %} |
24 | | - <a href="{{ prev_url | relative_url }}" class="prev" title="{{ prev_doc.title }}">Back</a> |
| 47 | + <a href="{{ prev_doc.url | relative_url }}" class="prev" title="{{ prev_doc.title }}">Back</a> |
25 | 48 | {% endif %} |
26 | 49 | </div> |
27 | 50 | <div class="right align-left"> |
28 | 51 | {% if forloop.last %} |
29 | 52 | <span class="next disabled">Next</span> |
30 | 53 | {% else %} |
31 | 54 | {% assign next = forloop.index0 | plus: 1 %} |
32 | | - {% assign next_url = docs[next] | prepend:"/docs/" | append:"/" %} |
| 55 | + {% assign next_url = docs[next] %} |
33 | 56 | {% assign next_doc = site.docs | where: "url", next_url | first %} |
34 | | - <a href="{{ next_url | relative_url }}" class="next" title="{{ next_doc.title }}">Next</a> |
| 57 | + <a href="{{ next_doc.url | relative_url }}" class="next" title="{{ next_doc.title }}">Next</a> |
35 | 58 | {% endif %} |
36 | 59 | </div> |
37 | 60 | </div> |
|
0 commit comments