Skip to content

Commit 53807ba

Browse files
authored
Merge pull request open-neuromorphic#247 from neural-loop/design-adjustments
feat(neuromorphic-hardware): Add next article navigation
2 parents 520d5e5 + aed7882 commit 53807ba

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{ $next_page := . }}
2+
3+
{{ if $next_page }}
4+
<div class="next-article-card-container mt-8 border-t border-border dark:border-darkmode-border pt-6">
5+
<a href="{{ $next_page.RelPermalink }}" class="next-article-card group block p-4">
6+
<div class="flex items-center gap-4">
7+
8+
<div class="flex-shrink-0">
9+
{{ $image_res := "" }}
10+
{{ with $next_page.Params.image }}
11+
{{ $image_res = $next_page.Resources.GetMatch . }}
12+
{{ end }}
13+
14+
{{ if $image_res }}
15+
{{ $thumb := $image_res.Fill "80x80 Lanczos" }}
16+
<img src="{{ $thumb.RelPermalink }}" alt="Image of {{ $next_page.Title }}" class="w-20 h-20 object-cover rounded-md">
17+
{{ else }}
18+
<div class="w-20 h-20 bg-gray-200 dark:bg-darkmode-theme-dark flex items-center justify-center rounded-md">
19+
{{ partial "icon.html" (dict "style" "solid" "name" "microchip" "class" "text-3xl text-gray-400") }}
20+
</div>
21+
{{ end }}
22+
</div>
23+
24+
<div class="flex-grow">
25+
<p class="text-sm font-medium text-gray-500 dark:text-gray-400">Next article</p>
26+
<h4 class="text-md font-bold text-dark dark:text-darkmode-dark group-hover:text-primary dark:group-hover:text-darkmode-primary transition-colors">
27+
{{ $next_page.Title }}
28+
</h4>
29+
<span class="text-sm text-primary dark:text-darkmode-primary font-semibold mt-1 inline-block">
30+
Continue reading {{ partial "icon.html" (dict "style" "solid" "name" "arrow-right" "class" "inline-block transform transition-transform duration-200 group-hover:translate-x-1") }}
31+
</span>
32+
</div>
33+
</div>
34+
</a>
35+
</div>
36+
{{ end }}

layouts/partials/components/sidebar-toc-shared.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@
1212
<div id="tableOfContentContainer" class="max-h-[calc(100vh-28rem)] overflow-y-auto">
1313
{{ .TableOfContents }}
1414
</div>
15+
16+
{{/* --- START: New 'Next Article' Logic --- */}}
17+
{{ if eq .Type "neuromorphic-hardware" }}
18+
{{ $all_hardware := where site.RegularPages "Type" "neuromorphic-hardware" }}
19+
{{ $grouped_by_year := $all_hardware.GroupByParam "product.release_year" }}
20+
{{ $sorted_groups := sort $grouped_by_year "Key" "desc" }}
21+
22+
{{ $sorted_hardware := slice }}
23+
{{ range $sorted_groups }}
24+
{{ $pages_in_year := sort .Pages "Title" "asc" }}
25+
{{ $sorted_hardware = $sorted_hardware | append $pages_in_year }}
26+
{{ end }}
27+
28+
{{ $currentPageIndex := -1 }}
29+
{{ range $index, $page := $sorted_hardware }}
30+
{{ if eq $page.Permalink $.Permalink }}
31+
{{ $currentPageIndex = $index }}
32+
{{ end }}
33+
{{ end }}
34+
35+
{{ if and (ne $currentPageIndex -1) (lt $currentPageIndex (sub (len $sorted_hardware) 1)) }}
36+
{{ $nextPageIndex := add $currentPageIndex 1 }}
37+
{{ $next_page := index $sorted_hardware $nextPageIndex }}
38+
{{ partial "components/next-article-card.html" $next_page }}
39+
{{ end }}
40+
{{ end }}
41+
{{/* --- END: New 'Next Article' Logic --- */}}
42+
1543
</div>
1644
</div>
1745
</aside>

0 commit comments

Comments
 (0)