Skip to content

Commit e0b7060

Browse files
author
Robin Marillia
committed
add working prev and next links
1 parent da8c189 commit e0b7060

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

docs/Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ GEM
9898
faraday (> 0.8, < 2.0)
9999

100100
PLATFORMS
101+
universal-darwin-21
101102
x86_64-linux
102103

103104
DEPENDENCIES

docs/_layouts/guide.html

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,41 @@
22
layout: default
33
---
44

5+
{% assign sidebarItems = site.guide | sort: 'chapter' %}
6+
7+
{% for item in sidebarItems %}
8+
{% if item.title == page.title %}
9+
{% unless forloop.first %}
10+
{% assign prevIndex = forloop.index| minus: 2 %}
11+
{% assign prev = sidebarItems[prevIndex] %}
12+
{% endunless %}
13+
{% unless forloop.last %}
14+
{% assign nextIndex = forloop.index %}
15+
{% assign next = sidebarItems[nextIndex] %}
16+
{% endunless %}
17+
{% endif %}
18+
{% endfor %}
19+
520
<div class="d-md-flex flex-1">
6-
{% assign sidebarItems = site.guide | sort: 'chapter' %} {% include sidebar.html %}
21+
{% include sidebar.html %}
722

823
<section class="col-lg-9 px-5 f4">
924
<div class="container-md markdown-body mb-5">
1025
<h1 class="mb-4 f0-light">{{ page.title }}</h1>
1126
{{ content }}
12-
<div class="mt-4 Box">
13-
<nav class="paginate-container Box-body" aria-label="Pagination">
14-
<div class="pagination">
15-
{% if page.previous %}
16-
<span class="previous_page" aria-disabled="true">Previous</span>
17-
{% else %}
18-
<a class="previous_page" rel="previous" href="{{page.previous.url}}" aria-label="Previous Page">Previous</a>
19-
{% endif %} {% if page.next %}
20-
<span class="next_page" aria-disabled="true">Next</span>
21-
{% else %}
22-
<a class="next_page" rel="next" href="{{page.next.url}}" aria-label="Next Page">Next</a>
23-
{% endif %}
24-
</div>
27+
<div class="mt-4">
28+
<nav class="prev-next-links" aria-label="Pagination">
29+
{% if prev %}
30+
<a class="prev-next-links__button" rel="previous" href="{{prev.url}}" aria-label="Previous Page">
31+
<div class="f6 text-uppercase">Previous</div>
32+
{{prev.title}}
33+
</a>
34+
{% endif %} {% if next %}
35+
<a class="prev-next-links__button" rel="next" href="{{next.url}}" aria-label="Next Page">
36+
<div class="f6 text-uppercase">Next</div>
37+
{{next.title}}
38+
</a>
39+
{% endif %}
2540
</nav>
2641
</div>
2742
</div>

docs/custom.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@ a {
103103
.code-tooltip {
104104
scroll-margin-top: 150px;
105105
}
106+
107+
108+
/* Prev and next links */
109+
.prev-next-links {
110+
display: flex;
111+
gap: 16px;
112+
}
113+
114+
.prev-next-links__button {
115+
border: solid 1px;
116+
padding: 16px;
117+
border-radius: 4px;
118+
flex: 1;
119+
}

0 commit comments

Comments
 (0)