Skip to content

Commit edf3ba4

Browse files
feat: bottom page navigation component (#2085)
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
1 parent 17da555 commit edf3ba4

33 files changed

Lines changed: 123 additions & 22 deletions

_config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ defaults:
7272

7373
announcement: true # Enable or disable the announcements.
7474

75+
collections:
76+
starter:
77+
output: true
78+
sort_by: order
79+
guide:
80+
output: true
81+
sort_by: order
82+
advanced:
83+
output: true
84+
sort_by: order
85+
resources:
86+
output: true
87+
sort_by: order
88+
7589
# Build settings
7690

7791
plugins:
@@ -88,7 +102,7 @@ kramdown:
88102
hard_wrap: false
89103
syntax_highlighter: rouge
90104

91-
exclude:
105+
exclude:
92106
- [uk/CHANGELOG.md]
93107
- vendor/bundle
94108
- node_modules/

_includes/bottom-navigation.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% assign current_menu = page.menu %}
2+
{% assign current_lang = page.lang %}
3+
4+
{% if current_menu and current_lang %}
5+
6+
{% assign all_pages_in_menu = site.pages | where: "menu", current_menu %}
7+
{% assign lang_specific_pages = all_pages_in_menu | where: "lang", current_lang %}
8+
9+
{% assign sorted_pages = lang_specific_pages | sort: "order" %}
10+
11+
{% for doc in sorted_pages %}
12+
{% if doc.path == page.path %}
13+
{% assign current_index = forloop.index0 %}
14+
{% break %}
15+
{% endif %}
16+
{% endfor %}
17+
18+
{% if current_index != nil %}
19+
{% assign prev_index = current_index | minus: 1 %}
20+
{% if prev_index >= 0 %}
21+
{% assign prev_page = sorted_pages[prev_index] %}
22+
{% endif %}
23+
24+
{% assign next_index = current_index | plus: 1 %}
25+
{% if next_index < sorted_pages.size %}
26+
{% assign next_page = sorted_pages[next_index] %}
27+
{% endif %}
28+
{% endif %}
29+
30+
{% if prev_page or next_page %}
31+
<nav class="bottom-navigation" aria-label="Pagination">
32+
{% if prev_page %}
33+
<a href="{{ prev_page.url | relative_url }}" class="bottom-nav-prev">
34+
Previous: {{ prev_page.title }}
35+
</a>
36+
{% endif %}
37+
38+
{% if next_page %}
39+
<a href="{{ next_page.url | relative_url }}" class="bottom-nav-next">
40+
Next: {{ next_page.title }}
41+
</a>
42+
{% endif %}
43+
</nav>
44+
{% endif %}
45+
46+
{% endif %}

_includes/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
</ul>
177177
</li>
178178
<li id="resources-menu" class="submenu">
179-
<a href="/{{ page.lang }}/resources/glossary.html" {% if page.menu=='resources' %} class="active" {% endif %}>
179+
<a href="/{{ page.lang }}/resources/community.html" {% if page.menu=='resources' %} class="active" {% endif %}>
180180
{{ site.data[page.lang].menu.resources }}
181181
</a>
182182
<ul class="submenu-content">

_layouts/page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<div class="content">
2929
<main>
3030
{{ content }}
31+
{% include bottom-navigation.html %}
3132
{% include github-edit-btn.html %}
3233
</main>
3334
</div>

css/style.css

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,16 @@ div.header-btn {
688688
color: var(--box-fg);
689689
}
690690

691-
a.edit-github-btn{
691+
a.edit-github-btn,
692+
a.bottom-nav-prev,
693+
a.bottom-nav-next {
692694
display: flex;
693695
gap: 0.5rem;
694696
align-items: center;
695697
width: fit-content;
696698
padding: 0.5rem;
697699
border-radius: 0.3rem;
700+
text-decoration: none;
698701

699702
&:is(:hover, :active, :focus) {
700703
color: var(--fg);
@@ -1171,6 +1174,26 @@ h2 a {
11711174
}
11721175
}
11731176

1177+
/* 'Prev' left and 'Next' right btn */
1178+
.bottom-navigation {
1179+
display: flex;
1180+
justify-content: space-between;
1181+
flex-wrap: wrap;
1182+
margin-block: 1rem;
1183+
font-weight: 500;
1184+
font-size: 1.2rem;
1185+
}
1186+
1187+
.bottom-nav-prev {
1188+
text-align: left;
1189+
max-width: 50%;
1190+
}
1191+
1192+
.bottom-nav-next {
1193+
text-align: right;
1194+
max-width: 50%;
1195+
}
1196+
11741197
/* routing methods columns */
11751198
.methods-columns {
11761199
display: flex;
@@ -1739,3 +1762,4 @@ blockquote {
17391762
}
17401763
}
17411764

1765+

en/advanced/best-practice-performance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: page
33
title: Performance Best Practices Using Express in Production
44
description: Discover performance and reliability best practices for Express apps in production, covering code optimizations and environment setups for optimal performance.
55
menu: advanced
6+
order: 4
67
redirect_from: "/advanced/best-practice-performance.html"
78
---
89
# Production best practices: performance and reliability

en/advanced/best-practice-security.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: page
33
title: Security Best Practices for Express in Production
44
description: Discover crucial security best practices for Express apps in production, including using TLS, input validation, secure cookies, and preventing vulnerabilities.
55
menu: advanced
6+
order: 3
67
redirect_from: "/advanced/best-practice-security.html"
78
---
89

en/advanced/developing-template-engines.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: page
33
title: Developing template engines for Express
44
description: Learn how to develop custom template engines for Express.js using app.engine(), with examples on creating and integrating your own template rendering logic.
55
menu: advanced
6+
order: 1
67
redirect_from: "/advanced/developing-template-engines.html"
78
---
89

en/advanced/healthcheck-graceful-shutdown.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: page
33
title: Health Checks and Graceful Shutdown
44
description: Learn how to implement health checks and graceful shutdown in Express apps to enhance reliability, manage deployments, and integrate with load balancers like Kubernetes.
55
menu: advanced
6+
order: 5
67
redirect_from: "/advanced/healthcheck-graceful-shutdown.html"
78
---
89

en/advanced/security-updates.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: page
33
title: Express security updates
44
description: Review the latest security updates and patches for Express.js, including detailed vulnerability lists for different versions to help maintain a secure application.
55
menu: advanced
6+
order: 2
67
redirect_from: "/advanced/security-updates.html"
78
---
89

0 commit comments

Comments
 (0)