File tree Expand file tree Collapse file tree 5 files changed +57
-5
lines changed
Expand file tree Collapse file tree 5 files changed +57
-5
lines changed Original file line number Diff line number Diff line change 11< nav class ="book-nav ">
2- < h2 > {{ site.title }} </ h2 >
2+ < h2 > Chapters </ h2 >
33 < ul >
44 {% for item in site.navigation %}
55 < li >
6- < a href ="{{ site.baseurl }}{{ item.url }} " {% if page.url == item.url %}class ="active "{% endif %} >
6+ < a href ="{{ item.url | relative_url }} " {% if page.url contains item.url %}class ="active "{% endif %} >
77 {{ item.title }}
88 </ a >
99 </ li >
Original file line number Diff line number Diff line change 1+ {% comment %}
2+ Generate previous/next navigation links based on nav_order
3+ {% endcomment %}
4+
5+ {% assign current_order = page.nav_order | default: 1 %}
6+ {% assign prev_page = nil %}
7+ {% assign next_page = nil %}
8+
9+ {% comment %} Find all pages and sort by nav_order {% endcomment %}
10+ {% assign sorted_pages = site.pages | where_exp: "item", "item.nav_order" | sort: "nav_order" %}
11+
12+ {% for p in sorted_pages %}
13+ {% if p.nav_order < current _order %}
14+ {% assign prev_page = p %}
15+ {% endif %}
16+ {% if p.nav_order > current_order and next_page == nil %}
17+ {% assign next_page = p %}
18+ {% endif %}
19+ {% endfor %}
20+
21+ < nav class ="page-navigation ">
22+ < div class ="prev ">
23+ {% if prev_page %}
24+ < a href ="{{ prev_page.url | relative_url }} "> ← {{ prev_page.title }}</ a >
25+ {% endif %}
26+ </ div >
27+ < div class ="next ">
28+ {% if next_page %}
29+ < a href ="{{ next_page.url | relative_url }} "> {{ next_page.title }} →</ a >
30+ {% endif %}
31+ </ div >
32+ </ nav >
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ <h1><a href="{{ '/' | relative_url }}">{{ site.title }}</a></h1>
3232
3333 {{ content }}
3434
35+ {% if page.nav_order %}
36+ {% include page-nav.html %}
37+ {% endif %}
38+
3539 </ section >
3640 < footer >
3741 < p > < small > {{ site.tagline }}</ small > </ p >
Original file line number Diff line number Diff line change @@ -133,19 +133,34 @@ ul, ol {
133133.page-navigation {
134134 display : flex;
135135 justify-content : space-between;
136+ align-items : center;
136137 margin-top : 40px ;
137138 padding-top : 20px ;
138139 border-top : 1px solid # e5e5e5 ;
140+ gap : 20px ;
141+ }
142+
143+ .page-navigation .prev {
144+ flex : 1 ;
145+ text-align : left;
146+ }
147+
148+ .page-navigation .next {
149+ flex : 1 ;
150+ text-align : right;
139151}
140152
141153.page-navigation a {
154+ display : inline-block;
142155 padding : 10px 15px ;
143156 background-color : # f5f5f5 ;
144157 border-radius : 3px ;
145158 text-decoration : none;
146159 color : # 333 ;
160+ transition : all 0.2s ;
147161}
148162
149163.page-navigation a : hover {
150- background-color : # e5e5e5 ;
164+ background-color : # 4078c0 ;
165+ color : white;
151166}
Original file line number Diff line number Diff line change 11---
22layout : default
3- title : " Reactive: A React Book for the Reluctant"
3+ title : " Home"
4+ nav_order : 1
45---
56
67# Reactive: A React Book for the Reluctant
@@ -78,7 +79,7 @@ Everything you need to know about React, including:
7879
7980<div align =" center " >
8081
81- ** [ Start Reading →] ( 01-table-of-contents ) **
82+ ** [ Start Reading →] ({{ '/ 01-table-of-contents' | relative_url }} )**
8283
8384* Warning: Reading this book will teach you React.*
8485* We apologize in advance.*
You can’t perform that action at this time.
0 commit comments