aboutsummaryrefslogtreecommitdiff
path: root/templates/_nav.html
blob: 1188b5d1df0b94ee8931c8813f80afbfc4134914 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{% macro navsection(hierarchy, level, current) %}
  {% set sec = hierarchy | nth(n=level) %}
  {% set sec = get_section(path=sec) %}
  {% set maxlevel = hierarchy | length %}

  {# Ici on regarde si toutes les sous-sections et pages contenues ont #}
  {# une variable weight_custom                                        #}
  {% set temoin = true %}
  {% set liste = [] %}
  {% if sec.subsections %}
    {% for s in sec.subsections %}
      {% set s_temp = get_section(path=s) %}
      {% if not s_temp.extra.weight_custom %}
        {% set_global temoin = false %}
      {% else %}
        {% set_global liste = liste | concat(with=s_temp) %}
      {% endif %}
    {% endfor %}
  {% endif %}
  {% if sec.pages %}
    {% for p in sec.pages %}
      {% if not p.extra.weight_custom %}
        {% set_global temoin = false %}
      {% else %}
        {% set_global liste = liste | concat(with=p) %}
      {% endif %}
    {% endfor %}
  {% endif %}

  {# Si toutes les sous-sections et pages ont une variable weight_custom, #}
  {# on classe selon elle. Sinon, on utilise la méthode classique.        #}
  {% if temoin %}
    // classer ici










  {% else %}
    {% if sec.subsections %}
      {% for s in sec.subsections %}
        {% set p = get_section(path=s) %}
        <div class="toc-item">
          {% if p.subsections or p.pages %}
            {% if p.path == current.path %}
              <a class="subtext" href="{{ p.permalink | safe}}"><b>{{ p.title }}</b></a>
            {% elif hierarchy is containing(s) %}
              <a class="subtext" href="{{ p.permalink | safe}}">{{ p.title }}</a>
            {% else %}
              <a class="subtext" href="{{ p.permalink | safe}}">{{ p.title }}</a>
            {% endif %}
            {% if hierarchy is containing(s) or current.path == p.path %}
              {% if level + 1 < maxlevel %}
                <div class="nav-subsection">
                  {{ nav::navsection(hierarchy=hierarchy,level=level + 1,current=current) }}
                </div>
              {% endif %}
            {% endif %}
          {% else %}
            {% if p.path == current.path %}
            <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
            {% else %}
              <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
            {% endif %}
          {% endif %}
        </div>
        {% endfor %}
    {% endif %}
  
    {% if sec.pages %}
      {% for p in sec.pages %}
        <div class="toc-item">
          {% if p.path == current.path %}
          <a class="subtext" href="{{p.permalink | safe}}"><b>{{ p.title }}</b></a>
          {% else %}
            <a class="subtext" href="{{p.permalink | safe}}">{{ p.title }}</a>
          {% endif %}
        </div>
      {% endfor %}
    {% endif %}
  {% endif %}	
{% endmacro navsection %}

{% macro navmenu(current) %}
  {% if current.ancestors %}
    {% set hierarchy = current.ancestors | slice(start=1) | concat(with=current.relative_path) %}
  {% else %}
    {% set hierarchy = [current.relative_path] %}
  {% endif %}

  {% set root_path = hierarchy | nth(n=0) %}
  {% set root = get_section(path=root_path) %}
  <div class="toc-item toc-section">
    <a class="subtext" href="{{root.permalink | safe}}">{{ root.title }}</a>
  </div>

  {{ nav::navsection(hierarchy=hierarchy,level=0,current=current) }}
{% endmacro %}