-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathsidebar-toc-multipage-overview.html
73 lines (70 loc) · 3.88 KB
/
sidebar-toc-multipage-overview.html
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
{% assign pagetype = page.type %}
<div class="content-nav">
<div class="inner-box sidebar-toc-wrapper" style="">
<h5 class="contents">Contents</h5>
{% if pagetype %}
<div class="inner-toc book" id="sidebar-toc">
{% else %}
<div class="inner-toc" id="sidebar-toc">
{% endif %}
<ul>
{% assign sorted = site[page.collection] | sort: 'num' %}
{% for pg in sorted %}
{% capture toc %}
{% if pg.num == page.num %}
<div id="toc"></div>
{% endif %}
{% endcapture %}
{% if pg.num and (page.partof == pg.partof) %}
{% if page.language %} <!-- if page is a translation, get the translated title -->
{% assign localizedId = pg.id %}
{% for lpg in site.[page.language] %}
{% if lpg.id == localizedId %}
{% if pg.type %} <!-- if a type is set in a document, we add it as a class. Used in Scala book to diff between chapter and section -->
<li class="type-{{ pg.type }}"><a {% if page.num == pg.num %}class="active"{% endif %} href="{{ site.baseurl }}{{ pg.url }}">{{ lpg.title }}</a>{{ toc }}</li>
{% else %}
<li><a {% if page.num == pg.num %}class="active"{% endif %} href="{{ site.baseurl }}{{ pg.url }}">{{ lpg.title }}</a>{{ toc }}</li>
{% endif %}
{% endif %}
{% endfor %}
{% else %} <!-- this must be English, so get the other documents' titles -->
{% if pg.type %} <!-- if a type is set in a document, we add it as a class. Used in Scala book to diff between chapter and section -->
<li class="type-{{ pg.type }}"><a {% if page.num == pg.num %}class="active"{% endif %} href="{{ site.baseurl }}{{ pg.url }}">{{ pg.title }}</a>{{toc}}</li>
{% else %}
<li><a {% if page.num == pg.num %}class="active"{% endif %} href="{{ site.baseurl }}{{ pg.url }}">{{ pg.title }}</a>{{toc}}</li>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</ul>
{% assign orphanTranslation = page.orphanTranslation | default: false %}
{% if page.languages %}
<ul id="available-languages" style="display: none;">
<li><a href="{{ site.baseurl }}{{ page.url }}">English</a></li>
{% for l in page.languages %}
{% capture intermediate %}{{ page.url }}{% endcapture %}
{% capture rootTutorialURL %}{{ intermediate | remove_first: '/' }}{% endcapture %}
{% assign lang = site.data.languages[l] %}
<li><a href="{{ site.baseurl }}/{{ l }}/{{ rootTutorialURL }}" class="lang">{{ lang.name }}</a></li>
{% endfor %}
</ul>
{% elsif page.language and orphanTranslation == false %}
{% comment %}
<!-- i.e. some pages like '/zh-cn/thanks.html' have no english version -->
{% endcomment %}
{% assign engId = page.id | remove_first: "/" | remove_first: page.language %}
{% assign engPath = engId | append: '.html' %}
{% assign engPg = site.overviews | where: 'partof', page.partof | find: 'id', engId %}
<ul id="available-languages" style="display: none;">
<li><a href="{{ site.baseurl }}{{ engPath }}">English</a></li>
{% for l in engPg.languages %}
{% assign lang = site.data.languages[l] %}
<li><a href="{{ site.baseurl }}/{{ l }}{{ engPath }}" class="lang">{{ lang.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
<hr>
<div class="help-us"><a href="https://github.com/scala/docs.scala-lang/blob/main/{% if page.collection %}{{ page.relative_path }}{% else %}{{ page.path }}{% endif %}"><i class="fa fa-pencil" aria-hidden="true"></i> Problem with this page?<br> Please help us fix it!</a></div>
</div>
</div>