File: section_nav_tutorials.html

package info (click to toggle)
jekyll 4.3.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,356 kB
  • sloc: ruby: 16,765; javascript: 1,455; sh: 214; xml: 29; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{%- comment -%}
Map grabs the tutorials sections, giving us an array of arrays. Join, flattens all
the items to a comma delimited string. Split turns it into an array again.
{%- endcomment -%}
{%- assign tutorials = site.data.tutorials | map: 'tutorials' | join: ',' | split: ',' -%}

{%- comment -%}
Because this is built for every page, lets find where we are in the ordered
document list by comparing url strings. Then if there's something previous or
next, lets build a link to it.
{%- endcomment -%}

{% for tutorial in tutorials -%}
  {% assign tutorial_url = tutorial | prepend:"/tutorials/" | append:"/" -%}
  {% if tutorial_url == page.url -%}
  <div class="section-nav">
    <div class="left align-right">
        {% if forloop.first -%}
          <span class="prev disabled">Back</span>
        {% else -%}
          {% assign previous = forloop.index0 | minus: 1 -%}
          {% assign previous_page = tutorials[previous] | prepend:"/tutorials/" | append:"/" -%}
          <a href="{{ previous_page | relative_url }}" class="prev">Back</a>
        {% endif -%}
    </div>
    <div class="right align-left">
        {% if forloop.last -%}
          <span class="next disabled">Next</span>
        {% else -%}
          {% assign next = forloop.index0 | plus: 1 -%}
          {% assign next_page = tutorials[next] | prepend:"/tutorials/" | append:"/" -%}
          <a href="{{ next_page | relative_url }}" class="next">Next</a>
        {% endif -%}
    </div>
  </div>
  <div class="clear"></div>
  {% break -%}
  {% endif -%}
{% endfor -%}