Remove software carpentries logo
[rnaseq-cwl-training.git] / _includes / base_path.html
1 {% comment %}
2 This is adapted from: https://ricostacruz.com/til/relative-paths-in-jekyll
3
4 `page.url` gives the URL of the current page with a leading /:
5
6 - when the URL ends with the extension (e.g., /foo/bar.html) then we can get
7   the depth by counting the number of / and remove - 1
8 - when the URL ends with a / (e.g. /foo/bar/) then the number / gives the depth
9   directly
10 {% endcomment %}
11
12 {% assign relative_root_path = '' %}
13
14 {% assign last_char = page.url | slice: -1 %}
15
16 {% if last_char == "/"}
17 {% assign offset = 0 %}
18 {% else %}
19 {% assign offset = 1 %}
20 {% endif %}
21
22 {% assign depth = page.url | split: '/' | size | minus: offset %}
23 {% if    depth <= 1 %}{% assign relative_root_path = '.' %}
24 {% elsif depth == 2 %}{% assign relative_root_path = '..' %}
25 {% elsif depth == 3 %}{% assign relative_root_path = '../..' %}
26 {% elsif depth == 4 %}{% assign relative_root_path = '../../..' %}
27 {% endif %}