{% comment %} The code below generates the sidebar according to some manually created table of contents in the _config.yml. We assume the pages are unique. {% endcomment %}
{% assign base_url = site.baseurl | append: "/" %} {% if page.url == base_url %}
Home
{% else %}
Home
{% endif %} {% comment %} Hack to get a single element array... {% endcomment %} {% assign pagelist = base_url | split: 'DONOTSPLIT!#@$' %} {% assign arraypath = base_url | split: 'DONOTSPLIT!#@$' %} {% assign pagelist = pagelist | concat: arraypath %} {% assign current_pagelist_index = pagelist | size %} {% for chapter in site.chapters %} {% assign node = site.pages | where: "path", chapter.path | first %} {% assign arraypath = chapter.path | split: 'DONOTSPLIT!#@$' %} {% assign pagelist = pagelist | concat: arraypath %} {% assign chapteridx = forloop.index %} {% if page.url == node.url %} {% assign current_pagelist_index = pagelist | size %} {% assign active = "active" %} {% else %} {% assign active = "" %} {% endif %}
{{ chapteridx }}.
{{ node.title }}
{% if chapter.sections %}
{% for section in chapter.sections %} {% assign snode = site.pages | where: "path", section.path | first %} {% assign arraypath = section.path | split: 'DONOTSPLIT!#@$' %} {% assign pagelist = pagelist | concat: arraypath %} {% if page.url == snode.url %} {% assign current_pagelist_index = pagelist | size %} {% assign active = "active" %} {% else %} {% assign active = "" %} {% endif %}
{{ chapteridx }}.{{ forloop.index }}.
{{ snode.title }}
{% endfor %}
{% endif %} {% endfor %} {% assign arraypath = pagelist | last | split: 'DONOTSPLIT!#@$' %} {% assign pagelist = pagelist | concat: arraypath %} {% comment %} Now we can compute the next and previous page! {% endcomment %} {% assign prev_pagelist_index = current_pagelist_index | minus: 2 %} {% assign page_next_path = pagelist[current_pagelist_index] %} {% assign page_prev_path = pagelist[prev_pagelist_index] %} {% assign page_next = site.pages | where: "path", page_next_path | first %} {% assign page_prev = site.pages | where: "path", page_prev_path | first %}
GitHub project
Light (default)
Rust
Coal
Navy
Ayu
{{ site.title }}
{{ page.title }}
{{ content }}