forked from anomalyco/guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-footer.html
More file actions
98 lines (74 loc) · 3.07 KB
/
post-footer.html
File metadata and controls
98 lines (74 loc) · 3.07 KB
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
{% if include.page_en_url %}
{% assign current_page_en_url = include.page_en_url %}
{% else %}
{% assign current_page_en_url = page.url %}
{% endif %}
{% comment %}
Loop through all the chapters in order to:
- create full array of chapters
- index english version of current chapter
{% endcomment %}
{% assign all_chapters = "" | split: "" %}
{% assign current = 0 %}
{% for sections in site.data.chapterlist %}
{% assign chapters = sections[1].chapters %}
{% for chapter in chapters %}
{% if chapter.url == current_page_en_url %}
{% assign index = current %}
{% endif %}
{% assign all_chapters = all_chapters | push: chapter %}
{% assign current = current | plus: 1 %}
{% for subchapter in chapter.subchapters %}
{% if subchapter.url == current_page_en_url %}
{% assign index = current %}
{% endif %}
{% assign all_chapters = all_chapters | push: subchapter %}
{% assign current = current | plus: 1 %}
{% endfor %}
{% endfor %}
{% endfor %}
{% assign size = all_chapters | size %}
<div class="post-footer">
<hr />
{% assign previous = index | minus: 1 %}
{% if previous != -1 %}
{% comment %} Set previous page based on current index {% endcomment %}
{% assign previous_url = all_chapters[previous].url %}
{% comment %} If non-english, find page same language previous page {% endcomment %}
{% if page.lang != "en" %}
{% comment %} If non-english, find ref of previous page {% endcomment %}
{% assign prev_pages = site.chapters | where:"url", previous_url %}
{% assign prev_page_ref = prev_pages[0].ref %}
{% if prev_page_ref %}
{% comment %} Find chapter of matching language and ref {% endcomment %}
{% assign cur_lang_pages = site.chapters | where:"ref", prev_page_ref | where:"lang", page.lang %}
{% if cur_lang_pages[0] %}
{% assign previous_url = cur_lang_pages[0].url %}
{% endif %}
{% endif %}
{% endif %}
<a class="previous" href="{{ previous_url }}">
← Previous
</a>
{% endif %}
<a class="toc" href="{% link guide.md %}#table-of-contents">Table of Contents</a>
{% assign next = index | plus: 1 %}
{% if next != size %}
{% comment %} Set next page based on current index {% endcomment %}
{% assign next_url = all_chapters[next].url %}
{% comment %} If non-english, find page same language next page {% endcomment %}
{% if page.lang != "en" %}
{% comment %} If non-english, find ref of next page {% endcomment %}
{% assign next_pages = site.chapters | where:"url", next_url %}
{% assign next_page_ref = next_pages[0].ref %}
{% if next_page_ref %}
{% comment %} Find chapter of matching language and ref {% endcomment %}
{% assign cur_lang_pages = site.chapters | where:"ref", next_page_ref | where:"lang", page.lang %}
{% if cur_lang_pages[0] %}
{% assign next_url = cur_lang_pages[0].url %}
{% endif %}
{% endif %}
{% endif %}
<a class="next" href="{{ next_url }}">Next →</a>
{% endif %}
</div>