2023-05-27 16:53:38 +03:00

86 lines
2.5 KiB
Plaintext

---
layout: layout.njk
---
<meta property="og:title" content="{{ title }}">
<meta property="og:site_name" content="Hypermedia Systems">
<header>
{% set prev = search.previousPage(url, "chapter!=undefined", "chapter") %}
{% set next = search.nextPage(url, "chapter!=undefined", "chapter") %}
<nav aria-label="Chapters navigation" class="<small>">
{% macro nav(show_toc=false) %}
<div class="grid spacious margin-block">
{% if prev or part %}
<p>
Previous:
{% if part %}
<a class="italic" href="/book/{{ part_url }}">{{ part }}</a>
{% else %}
<a href="{{ prev.data.url }}">{{ prev.data.title | safe }}</a>
{% endif %}
{% endif %}
{% if next %}
<p class="text-align:end" data-cols="2" data-cols@s="1">
<strong>
Next:
{% if next.data.part %}
<a class="italic" href="/book/{{ next.data.part_url }}">{{ next.data.part }}</a>
{% else %}
<a href="{{ next.data.url }}">{{ next.data.title | safe }}</a>
{% endif %}
</strong>
{% endif %}
</div>
{% endmacro %}
{{ nav(show_toc=true) }}
</nav>
<h1>
{% if chapter > 0 %}
<sub-title>
Chapter {{ chapter }}
</sub-title>
{% endif %}
{{ title | safe }}
</h1>
</header>
{% macro toc(block, level=0, url="") %}
{% set isPart = level == 0 and is_whole_book %}
{% set isChapter = level == 1 and is_whole_book %}
<ul class="nested-list">
{% for sect in block.getSections() %}
<li>
<a href="{{ url }}#{{ sect.getId() }}" class="{{ 'bold' if isPart or isChapter }}">
{{ 'Part ' + loop.index + ':' if isPart }}
{{ sect.getTitle() | safe }}
</a>
{{ toc(sect, level + 1, url=url) if level < 2 and sect.getSections().length > 0 }}
</li>
{% endfor %}
</ul>
{% endmacro %}
{% if asciidoc and asciidoc.getSections().length %}
<div class="container">
<details class="contents">
<summary>Contents</summary>
{{ asciidoc and toc(asciidoc, 0) }}
</details>
</div>
{% endif %}
<main>{{ content | safe }}</main>
<div class="container secondary-font">
{{ nav() }}
</div>
<footer>
<p>
{% include "global-footer.njk" %}
</p>
</footer>