This repository has been archived by the owner on Jun 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
/
tabs.html
72 lines (63 loc) · 3.26 KB
/
tabs.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
<div class="row docs-nav">
<div class="col-sm-8">
<ul class="nav nav-tabs visible-md-block visible-lg-block">
{% assign release_version = page.path | split:"/" | slice:1 | first %}
{% for tab in site.data.doc_categories[release_version] %}
{% assign tab_title_with_version = tab.title | append:" (" | append:release_version | append:")" %}
<li {% if page.category == tab_title_with_version %}class="active"{% endif %}>
<a href="{{ site.baseurl }}/{{ tab.href | replace:'$$VERSION$$',release_version }}">
{{ tab.title }}
</a>
</li>
{% endfor %}
</ul>
<ol class="breadcrumb visible-xs-block visible-sm-block">
<li><a href="{{ site.baseurl }}/docs/{{ release_version }}/">Docs</a></li>
<li class="active">{{ page.category }}</li>
</ol>
</div>
<div class="col-sm-4 version-dropdown">
<div class="btn-group" id="version-dropdown" style="margin-top: 1px; margin-bottom: 0; margin-right: 30px">
<a data-target="#version-dropdown" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
{{ release_version }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% comment %}
Liquid does not gives us an easy way to split a string at a specific
occurrence of a character, and keep the rest. Therefore, we use the
hack below.
'doc_name' is the document's name with repesct to Jekyll: where it
resides on the disk. The name looks something like:
"_docs/v0.0/dir/name/file.md"
The 'doc_name' is the portion of the file path after the top-level
_docs/ and version directory. It's how we access the inverted index to
tell which versions this document belongs to; it stays the same
between versions.
So, we split on slashes, and keep everything starting from the 2nd
index to the end. Hence the magic number '999' is meant to make sure
even deep hierarchies are kept.
We do the same with the 'url_name' for purposes of linking the specific
version of this file, except the URL structure looks like:
baseurl/docs/v0.0/dir/name/file/index.html
possibly, and we do not want the trailing "index.html".
{% endcomment %}
{% assign doc_name = page.path | split:"/" | slice:2,999 | join:"/" %}
{% assign url_name = page.url | split:"/" | slice:3,999 | join:"/" | remove:"index.html" %}
{% assign versions = site.data.doc_version_index[doc_name] | unshift:'latest' %}
{% unless versions %}
{% assign versions = 'latest' | split:' ' %}
{% endunless %}
{% for version in versions %}
<li {% if release_version == version %}class="active"{% endif %}><a href="{{ site.baseurl }}/docs/{{ version }}/{{ url_name }}">{{ version }}</a></li>
{% endfor %}
</ul>
</div>
<div class="edit-on-github visible-lg-inline-block visible-md-inline-block">
{% assign filename = page.path | split:"/" | last | downcase %}
<a class="icon github" href="{{ site.github.repository_url }}/edit/forsetisecurity.org/{{ page.path }}">
Edit this page
</a>
</div>
</div>
</div>