1
+ {{ $page_context := . }}
2
+ {{ $related_items := slice }}
3
+
4
+ {{ $current_type := $page_context.Type }}
5
+ {{ $current_slug := path.Base $page_context.File.Dir }}
6
+ {{ $current_title := $page_context.Title }}
7
+
8
+
9
+ {{/* --- Part 1: Find related content (blog, events) that tag this page --- */}}
10
+
11
+ {{ $tag_param_key := "" }}
12
+ {{ if eq $current_type "neuromorphic-hardware" }}
13
+ {{ $tag_param_key = ".Params.hardware_tags" }}
14
+ {{ else if eq $current_type "neuromorphic-software" }}
15
+ {{ $tag_param_key = ".Params.software_tags" }}
16
+ {{ end }}
17
+
18
+ {{ if ne $tag_param_key "" }}
19
+ {{ $tagged_pages := where site.RegularPages $tag_param_key "intersect" (slice $current_slug) }}
20
+ {{ range $tagged_pages }}
21
+ {{ $related_items = $related_items | append . }}
22
+ {{ end }}
23
+ {{ end }}
24
+
25
+
26
+ {{/* --- Part 2: Find related hardware/software (bidirectional linking) --- */}}
27
+
28
+ {{ if eq $current_type "neuromorphic-hardware" }}
29
+ {{/* I am a hardware page. Find software I support using my `software_tags` */}}
30
+ {{ with .Params.software_tags }}
31
+ {{ $software_slugs_to_find := . }}
32
+ {{ $all_software_pages := where site.RegularPages "Type" "neuromorphic-software" }}
33
+ {{ range $software_page := $all_software_pages }}
34
+ {{ $software_slug := path.Base $software_page.File.Dir }}
35
+ {{ if in $software_slugs_to_find $software_slug }}
36
+ {{ $related_items = $related_items | append $software_page }}
37
+ {{ end }}
38
+ {{ end }}
39
+ {{ end }}
40
+
41
+ {{ else if eq $current_type "neuromorphic-software" }}
42
+ {{/* I am a software page. Find hardware that supports me. */}}
43
+ {{ $hardware_pages := where site.RegularPages "Type" "neuromorphic-hardware" }}
44
+ {{ range where $hardware_pages ".Params.software_tags" "intersect" (slice $current_slug) }}
45
+ {{ $related_items = $related_items | append . }}
46
+ {{ end }}
47
+ {{ end }}
48
+
49
+ {{/* --- Finalize and Render --- */}}
50
+ {{/* Deduplicate without uniqBy for older Hugo versions */}}
51
+ {{ $unique_related_items := slice }}
52
+ {{ $seen_permalinks := slice }}
53
+ {{ range $related_items }}
54
+ {{ if not (in $seen_permalinks .Permalink) }}
55
+ {{ $unique_related_items = $unique_related_items | append . }}
56
+ {{ $seen_permalinks = $seen_permalinks | append .Permalink }}
57
+ {{ end }}
58
+ {{ end }}
59
+ {{ $sorted_related_items := sort $unique_related_items "Date" "desc" }}
60
+
61
+
62
+ {{ if $sorted_related_items }}
63
+ < div class ="related-content-section mt-12 pt-8 pb-8 ">
64
+ < h2 class ="text-3xl font-bold mb-8 "> Related Content, Events & Resources</ h2 >
65
+
66
+ < div class ="space-y-6 ">
67
+ {{ range $item := $sorted_related_items }}
68
+ < div class ="timeline-item-content ">
69
+ < div class ="flex flex-col md:flex-row items-start gap-5 ">
70
+
71
+ {{/* Thumbnail Column */}}
72
+ < div class ="flex-shrink-0 w-full md:w-40 text-center ">
73
+ < a href ="{{ $item.RelPermalink }} ">
74
+ {{ $image_param := $item.Params.image }}
75
+ {{ $img_path := "" }}
76
+ {{ $img_alt := $item.Title }}
77
+
78
+ {{ if $image_param }}
79
+ {{ $img_path_cleaned := strings.TrimPrefix "/" $image_param }}
80
+ {{ $resource := "" }}
81
+ {{ with $item.Resources.GetMatch $image_param }}
82
+ {{ $resource = . }}
83
+ {{ else }}
84
+ {{ with resources.Get $img_path_cleaned }}
85
+ {{ $resource = . }}
86
+ {{ end }}
87
+ {{ end }}
88
+
89
+ {{ if $resource }}
90
+ {{ $img_path = ($resource.Fill "160x90 Lanczos").RelPermalink }}
91
+ {{ else if fileExists (printf "static/%s" $img_path_cleaned) }}
92
+ {{ $img_path = $image_param | relURL }}
93
+ {{ end }}
94
+ {{ end }}
95
+
96
+ {{ if not $img_path }}
97
+ {{ with resources.Get "images/workshop-thumbnail-default.png" }}
98
+ {{ $img_path = (.Fill "160x90 Lanczos").RelPermalink }}
99
+ {{ $img_alt = "Default Open Neuromorphic Event Thumbnail" }}
100
+ {{ end }}
101
+ {{ end }}
102
+
103
+ {{ if $img_path }}
104
+ < img src ="{{ $img_path }} " alt ="{{ $img_alt }} " class ="w-full h-auto rounded-md object-cover ">
105
+ {{ else }}
106
+ < div class ="w-full h-[90px] bg-gray-200 dark:bg-darkmode-theme-dark rounded-md flex items-center justify-center ">
107
+ {{ partial "icon.html" (dict "style" "regular" "name" "images" "class" "text-4xl text-gray-400") }}
108
+ </ div >
109
+ {{ end }}
110
+ </ a >
111
+ </ div >
112
+
113
+ {{/* Content Column */}}
114
+ < div class ="flex-grow ">
115
+ < div class ="flex justify-between items-start gap-4 ">
116
+ < div >
117
+ < h4 class ="text-xl font-semibold mb-1 ">
118
+ < a href ="{{ $item.RelPermalink }} " class ="text-dark dark:text-darkmode-dark hover:text-primary dark:hover:text-darkmode-primary "> {{ $item.Title }}</ a >
119
+ </ h4 >
120
+ {{ with $item.Params.date }}
121
+ < p class ="text-sm text-gray-500 dark:text-gray-400 ">
122
+ {{ .Format "January 2, 2006" }}
123
+ </ p >
124
+ {{ end }}
125
+ </ div >
126
+ < span class ="timeline-item-badge flex-shrink-0 ">
127
+ {{- $item_type := "" -}}
128
+ {{- if eq $item.Type "neuromorphic-hardware" -}}
129
+ {{- $item_type = "Hardware" -}}
130
+ {{- else if eq $item.Type "neuromorphic-software" -}}
131
+ {{- $item_type = "Software" -}}
132
+ {{- else -}}
133
+ {{- $item_type = $item.Type | default $item.Section | humanize | title -}}
134
+ {{- end -}}
135
+ {{- $item_type -}}
136
+ </ span >
137
+ </ div >
138
+ {{ if $item.Description }}
139
+ < p class ="text-gray-600 dark:text-gray-400 mt-3 text-sm "> {{ $item.Description | truncate 150 }}</ p >
140
+ {{ end }}
141
+ </ div >
142
+
143
+ </ div >
144
+ </ div >
145
+ {{ end }}
146
+ </ div >
147
+ </ div >
148
+ {{ end }}
0 commit comments