|
6 | 6 | {{ $recurringEventData := site.Data.recurring_events.events }} |
7 | 7 | {{ $upcomingHackingHourDetails := "" }} |
8 | 8 | {{ range $recurringEventData }} |
9 | | - {{ if and (eq .id "hacking-hours") .active }} |
10 | | - {{ $now := now }} |
11 | | - {{ $daysMap := dict "Sunday" 0 "Monday" 1 "Tuesday" 2 "Wednesday" 3 "Thursday" 4 "Friday" 5 "Saturday" 6 }} |
12 | | - {{ $targetDayKey := .day_of_week | default "Monday" }} |
13 | | - {{ $targetDayIndex := index $daysMap $targetDayKey | default 1 }} |
14 | | - {{ $currentDayIndex := int $now.Weekday }} |
15 | | - {{ $daysToAdd := sub $targetDayIndex $currentDayIndex }} |
16 | | - {{ if lt $daysToAdd 0 }}{{ $daysToAdd = add $daysToAdd 7 }}{{ end }} |
17 | | - {{ if eq $daysToAdd 0 }} |
18 | | - {{ $eventStartHour := int (substr .start_time 0 2) }} |
19 | | - {{ $eventStartMinute := int (substr .start_time 3 2) }} |
20 | | - {{ $nowHour := $now.Hour }} |
21 | | - {{ $nowMinute := $now.Minute }} |
22 | | - {{ if or (gt $nowHour $eventStartHour) (and (eq $nowHour $eventStartHour) (ge $nowMinute $eventStartMinute)) }} |
23 | | - {{ $daysToAdd = 7 }} |
24 | | - {{ end }} |
25 | | - {{ end }} |
26 | | - {{ $nextOccurrenceDate := $now.AddDate 0 0 (int $daysToAdd) }} |
27 | | - {{ $upcomingHackingHourDetails = dict |
28 | | - "Title" .title |
29 | | - "Date" $nextOccurrenceDate |
30 | | - "StartTime" .start_time |
31 | | - "EndTime" .end_time |
32 | | - "TimeZone" .time_zone |
33 | | - "Permalink" (.details_page_link | relLangURL) |
34 | | - "Description" .description |
35 | | - "Host" .host |
36 | | - "LocationName" .location_name |
37 | | - "LocationURL" .location_url |
38 | | - "Image" .image |
39 | | - }} |
40 | | - {{ end }} |
| 9 | +{{ if and (eq .id "hacking-hours") .active }} |
| 10 | +{{ $now := now }} |
| 11 | +{{ $daysMap := dict "Sunday" 0 "Monday" 1 "Tuesday" 2 "Wednesday" 3 "Thursday" 4 "Friday" 5 "Saturday" 6 }} |
| 12 | +{{ $targetDayKey := .day_of_week | default "Monday" }} |
| 13 | +{{ $targetDayIndex := index $daysMap $targetDayKey | default 1 }} |
| 14 | +{{ $currentDayIndex := int $now.Weekday }} |
| 15 | +{{ $daysToAdd := sub $targetDayIndex $currentDayIndex }} |
| 16 | +{{ if lt $daysToAdd 0 }}{{ $daysToAdd = add $daysToAdd 7 }}{{ end }} |
| 17 | +{{ if eq $daysToAdd 0 }} |
| 18 | +{{ $eventStartHour := int (substr .start_time 0 2) }} |
| 19 | +{{ $eventStartMinute := int (substr .start_time 3 2) }} |
| 20 | +{{ $nowHour := $now.Hour }} |
| 21 | +{{ $nowMinute := $now.Minute }} |
| 22 | +{{ if or (gt $nowHour $eventStartHour) (and (eq $nowHour $eventStartHour) (ge $nowMinute $eventStartMinute)) }} |
| 23 | +{{ $daysToAdd = 7 }} |
| 24 | +{{ end }} |
| 25 | +{{ end }} |
| 26 | +{{ $nextOccurrenceDate := $now.AddDate 0 0 (int $daysToAdd) }} |
| 27 | +{{ $upcomingHackingHourDetails = dict |
| 28 | +"Title" .title |
| 29 | +"Date" $nextOccurrenceDate |
| 30 | +"StartTime" .start_time |
| 31 | +"EndTime" .end_time |
| 32 | +"TimeZone" .time_zone |
| 33 | +"Permalink" (.details_page_link | relLangURL) |
| 34 | +"Description" .description |
| 35 | +"Host" .host |
| 36 | +"LocationName" .location_name |
| 37 | +"LocationURL" .location_url |
| 38 | +"Image" .image |
| 39 | +}} |
| 40 | +{{ end }} |
41 | 41 | {{ end }} |
42 | 42 |
|
43 | 43 | {{ if or $mostRecentPastHH $upcomingHackingHourDetails }} |
44 | 44 | <div class="software-hacking-hours-promo bg-theme-light dark:bg-darkmode-theme-light p-6 rounded-lg shadow-lg mb-8"> |
45 | 45 | <div class="promo-content-wrapper md:flex md:items-start md:space-x-6"> |
46 | 46 |
|
47 | 47 | {{ if $mostRecentPastHH }} |
48 | | - <div class="past-event-promo flex-1 mb-6 md:mb-0 {{ if $upcomingHackingHourDetails }}md:border-r md:border-gray-300 dark:md:border-gray-600 md:pr-6{{ end }}"> |
49 | | - <h3 class="text-xl font-bold mb-3 text-text dark:text-darkmode-text">Latest Hacking Hour</h3> |
50 | | - <div class="flex items-start space-x-4"> |
51 | | - {{ $image := $mostRecentPastHH.Params.image }} |
52 | | - {{ $img_path := "" }} |
53 | | - {{ $img_alt := $mostRecentPastHH.Title }} |
54 | | - {{ if $image }} |
55 | | - {{ with $mostRecentPastHH.Resources.GetMatch $image }} {{ $img_path = (.Fill "120x67 Lanczos").RelPermalink }} {{ end }} |
56 | | - {{ if not $img_path }}{{ if fileExists (printf "static%s" $image) }}{{ $img_path = $image | relURL }}{{ end }}{{ end }} |
57 | | - {{ end }} |
58 | | - {{ if not $img_path }} |
59 | | - {{ with resources.Get "images/hacking-hours-default-banner.png" }} {{ $img_path = (.Fill "120x67 Lanczos").RelPermalink }} {{ end }} |
60 | | - {{ end }} |
| 48 | + <div class="past-event-promo flex-1 mb-6 md:mb-0 {{ if $upcomingHackingHourDetails }}md:border-r md:border-gray-300 dark:md:border-gray-600 md:pr-6{{ end }}"> |
| 49 | + <h3 class="text-xl font-bold mb-3 text-text dark:text-darkmode-text">Latest Hacking Hour</h3> |
| 50 | + <div class="flex items-start space-x-4"> |
| 51 | + {{/* --- START: MODIFIED IMAGE LOGIC --- */}} |
| 52 | + {{ $img_path := "" }} |
| 53 | + {{ $img_alt := $mostRecentPastHH.Title }} |
| 54 | + {{ $img_resource := "" }} |
| 55 | + |
| 56 | + {{/* 1. Check for `image` in front matter */}} |
| 57 | + {{ with $mostRecentPastHH.Params.image }} |
| 58 | + {{ with $mostRecentPastHH.Resources.GetMatch . }} |
| 59 | + {{ $img_resource = . }} |
| 60 | + {{ end }} |
| 61 | + {{ end }} |
| 62 | + |
| 63 | + {{/* 2. If not found, check for auto-generated OG image */}} |
| 64 | + {{ if not $img_resource }} |
| 65 | + {{ if $mostRecentPastHH.File }} |
| 66 | + {{ $page_slug := path.Base $mostRecentPastHH.File.Dir }} |
| 67 | + {{ $og_image_name := printf "%s-og-16x9.jpg" $page_slug }} |
| 68 | + {{ with $mostRecentPastHH.Resources.GetMatch $og_image_name }} |
| 69 | + {{ $img_resource = . }} |
| 70 | + {{ end }} |
| 71 | + {{ end }} |
| 72 | + {{ end }} |
| 73 | + |
| 74 | + {{/* 3. Final fallback to the default banner */}} |
| 75 | + {{ if not $img_resource }} |
| 76 | + {{ with resources.Get "images/hacking-hours-default-banner.png" }} |
| 77 | + {{ $img_resource = . }} |
| 78 | + {{ end }} |
| 79 | + {{ end }} |
61 | 80 |
|
62 | | - {{ if $img_path }} |
63 | | - <img src="{{ $img_path }}" alt="{{ $img_alt }}" class="w-30 h-auto rounded object-cover flex-shrink-0" style="width: 120px; height:67px;"> |
64 | | - {{ end }} |
65 | | - <div class="flex-grow"> |
66 | | - <h4 class="text-lg font-semibold leading-tight"><a href="{{ $mostRecentPastHH.RelPermalink }}" class="text-primary dark:text-darkmode-primary hover:underline">{{ $mostRecentPastHH.Title }}</a></h4> |
67 | | - <p class="text-xs text-gray-500 dark:text-gray-400 mb-1">{{ $mostRecentPastHH.Date.Format "January 2, 2006" }}</p> |
68 | | - <p class="text-sm text-gray-700 dark:text-gray-300">{{ $mostRecentPastHH.Description | truncate 80 }}</p> |
69 | | - </div> |
| 81 | + {{/* Process and render the selected image */}} |
| 82 | + {{ if $img_resource }} |
| 83 | + {{ $img_path = ($img_resource.Fill "120x67 Lanczos").RelPermalink }} |
| 84 | + <img src="{{ $img_path }}" alt="{{ $img_alt }}" class="w-30 h-auto rounded object-cover flex-shrink-0" style="width: 120px; height:67px;"> |
| 85 | + {{ end }} |
| 86 | + {{/* --- END: MODIFIED IMAGE LOGIC --- */}} |
| 87 | + <div class="flex-grow"> |
| 88 | + <h4 class="text-lg font-semibold leading-tight"><a href="{{ $mostRecentPastHH.RelPermalink }}" class="text-primary dark:text-darkmode-primary hover:underline">{{ $mostRecentPastHH.Title }}</a></h4> |
| 89 | + <p class="text-xs text-gray-500 dark:text-gray-400 mb-1">{{ $mostRecentPastHH.Date.Format "January 2, 2006" }}</p> |
| 90 | + <p class="text-sm text-gray-700 dark:text-gray-300">{{ $mostRecentPastHH.Description | truncate 80 }}</p> |
70 | 91 | </div> |
71 | 92 | </div> |
| 93 | + </div> |
72 | 94 | {{ end }} |
73 | 95 |
|
74 | 96 | {{ if $upcomingHackingHourDetails }} |
75 | | - <div class="upcoming-event-promo flex-1"> |
76 | | - <h3 class="text-xl font-bold mb-3 text-text dark:text-darkmode-text">Next Session</h3> |
77 | | - {{ with $upcomingHackingHourDetails.Image }} |
78 | | - {{ $defaultImgResourcePath := strings.TrimPrefix "/" . }} |
79 | | - {{ $defaultImg := resources.Get $defaultImgResourcePath }} |
80 | | - {{ if $defaultImg }} |
81 | | - {{ $thumb := $defaultImg.Fill "200x112 Lanczos" }} |
82 | | - <img src="{{ $thumb.RelPermalink }}" alt="Upcoming Hacking Hour" class="w-full h-auto rounded mb-3 object-cover" style="max-height: 112px;"> |
83 | | - {{ else if fileExists (printf "static%s" .) }} |
84 | | - <img src="{{ . | relURL }}" alt="Upcoming Hacking Hour" class="w-full h-auto rounded mb-3 object-cover" style="max-height: 112px;"> |
85 | | - {{ end }} |
86 | | - {{ end }} |
87 | | - <p class="text-md font-semibold text-primary dark:text-darkmode-primary flex items-baseline"> |
88 | | - {{ partial "icon.html" (dict "style" "regular" "name" "calendar" "class" "mr-2") }} |
89 | | - {{ $upcomingHackingHourDetails.Date.Format "Monday, January 2, 2006" }} |
90 | | - </p> |
91 | | - <p class="text-sm text-gray-600 dark:text-gray-400 flex items-baseline"> |
92 | | - {{ partial "icon.html" (dict "style" "regular" "name" "clock" "class" "mr-2") }} |
93 | | - {{ $upcomingHackingHourDetails.StartTime }} - {{ $upcomingHackingHourDetails.EndTime }} {{ $upcomingHackingHourDetails.TimeZone }} |
94 | | - </p> |
95 | | - <p class="text-sm text-gray-700 dark:text-gray-300 mt-2">{{ $upcomingHackingHourDetails.Description | truncate 100 }}</p> |
96 | | - <div class="mt-4 space-x-2"> |
97 | | - <a href="{{ $upcomingHackingHourDetails.LocationURL }}" target="_blank" class="btn btn-sm btn-new-primary"> |
98 | | - {{ partial "icon.html" (dict "style" "brands" "name" "discord" "class" "mr-2") }} Join on Discord |
99 | | - </a> |
100 | | - <a href="{{ $upcomingHackingHourDetails.Permalink }}" class="btn btn-sm btn-new-outline">Details</a> |
101 | | - </div> |
| 97 | + <div class="upcoming-event-promo flex-1"> |
| 98 | + <h3 class="text-xl font-bold mb-3 text-text dark:text-darkmode-text">Next Session</h3> |
| 99 | + {{ with $upcomingHackingHourDetails.Image }} |
| 100 | + {{ $defaultImgResourcePath := strings.TrimPrefix "/" . }} |
| 101 | + {{ $defaultImg := resources.Get $defaultImgResourcePath }} |
| 102 | + {{ if $defaultImg }} |
| 103 | + {{ $thumb := $defaultImg.Fill "200x112 Lanczos" }} |
| 104 | + <img src="{{ $thumb.RelPermalink }}" alt="Upcoming Hacking Hour" class="w-full h-auto rounded mb-3 object-cover" style="max-height: 112px;"> |
| 105 | + {{ else if fileExists (printf "static%s" .) }} |
| 106 | + <img src="{{ . | relURL }}" alt="Upcoming Hacking Hour" class="w-full h-auto rounded mb-3 object-cover" style="max-height: 112px;"> |
| 107 | + {{ end }} |
| 108 | + {{ end }} |
| 109 | + <p class="text-md font-semibold text-primary dark:text-darkmode-primary flex items-baseline"> |
| 110 | + {{ partial "icon.html" (dict "style" "regular" "name" "calendar" "class" "mr-2") }} |
| 111 | + {{ $upcomingHackingHourDetails.Date.Format "Monday, January 2, 2006" }} |
| 112 | + </p> |
| 113 | + <p class="text-sm text-gray-600 dark:text-gray-400 flex items-baseline"> |
| 114 | + {{ partial "icon.html" (dict "style" "regular" "name" "clock" "class" "mr-2") }} |
| 115 | + {{ $upcomingHackingHourDetails.StartTime }} - {{ $upcomingHackingHourDetails.EndTime }} {{ $upcomingHackingHourDetails.TimeZone }} |
| 116 | + </p> |
| 117 | + <p class="text-sm text-gray-700 dark:text-gray-300 mt-2">{{ $upcomingHackingHourDetails.Description | truncate 100 }}</p> |
| 118 | + <div class="mt-4 space-x-2"> |
| 119 | + <a href="{{ $upcomingHackingHourDetails.LocationURL }}" target="_blank" class="btn btn-sm btn-new-primary"> |
| 120 | + {{ partial "icon.html" (dict "style" "brands" "name" "discord" "class" "mr-2") }} Join on Discord |
| 121 | + </a> |
| 122 | + <a href="{{ $upcomingHackingHourDetails.Permalink }}" class="btn btn-sm btn-new-outline">Details</a> |
102 | 123 | </div> |
| 124 | + </div> |
103 | 125 | {{ end }} |
104 | 126 |
|
105 | 127 | </div> |
106 | 128 | </div> |
107 | 129 | {{ else }} |
108 | | - <!-- This fallback message is optional. If you prefer silence when no data, remove it. --> |
109 | | - <!-- <p class="text-center my-8 text-gray-600 dark:text-gray-400">No Hacking Hours information currently available.</p> --> |
| 130 | +<!-- This fallback message is optional. If you prefer silence when no data, remove it. --> |
| 131 | +<!-- <p class="text-center my-8 text-gray-600 dark:text-gray-400">No Hacking Hours information currently available.</p> --> |
110 | 132 | {{ end }} |
0 commit comments