2
2
{{ $related_items := slice }}
3
3
4
4
{{ $current_type := $page_context.Type }}
5
- {{ $current_slug := path.Base $page_context.File.Dir }}
5
+ {{ $current_slug := "" }}
6
+ {{ if $page_context.File }}
7
+ {{ $current_slug = path.Base $page_context.File.Dir }}
8
+ {{ end }}
6
9
{{ $current_title := $page_context.Title }}
7
10
8
11
15
18
{{ $tag_param_key = ".Params.software_tags" }}
16
19
{{ end }}
17
20
18
- {{ if ne $tag_param_key "" }}
21
+ {{ if and ( ne $tag_param_key "") (ne $current_slug "") }}
19
22
{{ $tagged_pages := where site.RegularPages $tag_param_key "intersect" (slice $current_slug) }}
20
23
{{ range $tagged_pages }}
21
24
{{ $related_items = $related_items | append . }}
31
34
{{ $software_slugs_to_find := . }}
32
35
{{ $all_software_pages := where site.RegularPages "Type" "neuromorphic-software" }}
33
36
{{ range $software_page := $all_software_pages }}
34
- {{ $software_slug := path.Base $software_page.File.Dir }}
35
- {{ if in $software_slugs_to_find $software_slug }}
37
+ {{ $software_slug := "" }}
38
+ {{ if $software_page.File }}{{ $software_slug = path.Base $software_page.File.Dir }}{{ end }}
39
+ {{ if and (ne $software_slug "") (in $software_slugs_to_find $software_slug) }}
36
40
{{ $related_items = $related_items | append $software_page }}
37
41
{{ end }}
38
42
{{ end }}
39
43
{{ end }}
40
44
41
- {{ else if eq $current_type "neuromorphic-software" }}
45
+ {{ else if and ( eq $current_type "neuromorphic-software") (ne $current_slug "") }}
42
46
{{/* I am a software page. Find hardware that supports me. */}}
43
47
{{ $hardware_pages := where site.RegularPages "Type" "neuromorphic-hardware" }}
44
48
{{ range where $hardware_pages ".Params.software_tags" "intersect" (slice $current_slug) }}
47
51
{{ end }}
48
52
49
53
{{/* --- Finalize and Render --- */}}
50
- {{/* Deduplicate without uniqBy for older Hugo versions */}}
54
+ {{/* Deduplicate */}}
51
55
{{ $unique_related_items := slice }}
52
56
{{ $seen_permalinks := slice }}
53
57
{{ range $related_items }}
@@ -68,47 +72,31 @@ <h2 class="text-3xl font-bold mb-8">Related Content, Events & Resources</h2>
68
72
< div class ="timeline-item-content ">
69
73
< div class ="flex flex-col md:flex-row items-start gap-5 ">
70
74
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 }}
75
+ {{/* Thumbnail Column - Renders only if image is in front matter */}}
76
+ {{ with $item.Params.image }}
77
+ < div class =" flex-shrink-0 w-full md:w-40 text-center ">
78
+ < a href =" {{ $item.RelPermalink }} " >
79
+ {{ $image_param := . }}
80
+ {{ $img_path := "" }}
81
+ {{ $img_alt := $item.Title }}
82
+
79
83
{{ $img_path_cleaned := strings.TrimPrefix "/" $image_param }}
80
84
{{ $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
-
85
+ {{ with $item.Resources.GetMatch $image_param }}{{ $resource = . }}{{ end }}
86
+ {{ if not $resource }}{{ with resources.Get $img_path_cleaned }}{{ $resource = . }}{{ end }}{{ end }}
87
+
89
88
{{ if $resource }}
90
89
{{ $img_path = ($resource.Fill "160x90 Lanczos").RelPermalink }}
91
90
{{ else if fileExists (printf "static/%s" $img_path_cleaned) }}
92
91
{{ $img_path = $image_param | relURL }}
93
92
{{ end }}
94
- {{ end }}
95
93
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" }}
94
+ {{ if $img_path }}
95
+ < img src ="{{ $img_path }} " alt ="{{ $img_alt }} " class ="w-full h-auto rounded-md object-cover ">
100
96
{{ 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 >
97
+ </ a >
98
+ </ div >
99
+ {{ end }}
112
100
113
101
{{/* Content Column */}}
114
102
< div class ="flex-grow ">
0 commit comments