|
| 1 | +{{/* layouts/partials/structured-markup/event.html */}} |
1 | 2 | {{ $page_context := . }}
|
2 | 3 | {{ $defaultOgImage := site.Params.metadata.image | default "images/og-image.png" | absLangURL }}
|
| 4 | + |
| 5 | +{{/* --- Date and Time Processing --- */}} |
3 | 6 | {{ $eventStartDate := "" }}{{ $eventEndDate := "" }}
|
4 | 7 | {{ if $page_context.Params.start_time }}
|
5 | 8 | {{ $eventStartDate = printf "%sT%s" ($page_context.Date.Format "2006-01-02") $page_context.Params.start_time }}
|
|
19 | 22 | {{ $offset = "Z" }}
|
20 | 23 | {{ end }}
|
21 | 24 |
|
| 25 | +{{/* --- Image Processing --- */}} |
22 | 26 | {{ $imagePath := $page_context.Params.image }}
|
23 | 27 | {{ $resolvedImageURL := "" }}
|
24 | 28 | {{ if $imagePath }}
|
|
28 | 32 | {{ with $page_context.Resources.GetMatch $imagePath }}
|
29 | 33 | {{ $resolvedImageURL = .Permalink }}
|
30 | 34 | {{ else }}
|
| 35 | +{{ with resources.Get $imagePath }} |
| 36 | +{{ $resolvedImageURL = .Permalink }} |
| 37 | +{{ else }} |
31 | 38 | {{ $resolvedImageURL = printf "%s%s" $page_context.RelPermalink $imagePath | absLangURL }}
|
32 | 39 | {{ end }}
|
33 | 40 | {{ end }}
|
| 41 | +{{ end }} |
34 | 42 | {{ else }}
|
35 | 43 | {{ $resolvedImageURL = $defaultOgImage }}
|
36 | 44 | {{ end }}
|
37 | 45 |
|
| 46 | +{{/* --- Event Status Logic --- */}} |
| 47 | +{{ $eventStatus := "https://schema.org/EventScheduled" }} |
| 48 | +{{ if eq .Params.upcoming false }} |
| 49 | +{{/* Event has passed. Google infers this from date, but we can be explicit if needed. |
| 50 | +For now, we'll let the presence of a VideoObject signal its new state. */}} |
| 51 | +{{ end }} |
| 52 | + |
| 53 | +{{/* --- Video Object Logic --- */}} |
| 54 | +{{ $videoObject := "" }} |
| 55 | +{{ with .Params.video }} |
| 56 | +{{ $videoObject = dict |
| 57 | +"@type" "VideoObject" |
| 58 | +"name" $page_context.Title |
| 59 | +"description" $page_context.Description |
| 60 | +"thumbnailUrl" (printf "https://i.ytimg.com/vi/%s/maxresdefault.jpg" .) |
| 61 | +"uploadDate" ($page_context.Date.Format "2006-01-02") |
| 62 | +"embedUrl" (printf "https://www.youtube.com/embed/%s" .) |
| 63 | +}} |
| 64 | +{{ end }} |
| 65 | + |
| 66 | + |
| 67 | +{{/* --- Main Event Schema Construction --- */}} |
38 | 68 | {{ $eventLD := dict
|
39 | 69 | "@context" "https://schema.org"
|
40 | 70 | "@type" "Event"
|
41 |
| -"name" $page_context.Params.Title |
| 71 | +"name" $page_context.Title |
42 | 72 | "startDate" (printf "%s%s" $eventStartDate $offset)
|
43 | 73 | "endDate" (printf "%s%s" $eventEndDate $offset)
|
44 |
| -"eventStatus" "https://schema.org/EventScheduled" |
| 74 | +"eventStatus" $eventStatus |
45 | 75 | "eventAttendanceMode" "https://schema.org/OnlineEventAttendanceMode"
|
46 |
| -"location" (dict "@type" "VirtualLocation" "url" "https://youtube.com/@openneuromorphic") |
| 76 | +"location" (dict |
| 77 | +"@type" "VirtualLocation" |
| 78 | +"url" (cond (ne .Params.video "") (printf "https://www.youtube.com/watch?v=%s" .Params.video) "https://youtube.com/@openneuromorphic") |
| 79 | +) |
47 | 80 | "image" (slice $resolvedImageURL)
|
48 |
| -"description" $page_context.Params.Description |
| 81 | +"description" $page_context.Description |
49 | 82 | "offers" (dict
|
50 | 83 | "@type" "Offer"
|
51 | 84 | "price" "0"
|
|
55 | 88 | "validFrom" ($page_context.Date.Format "2006-01-02T15:04:05Z07:00")
|
56 | 89 | )
|
57 | 90 | }}
|
| 91 | + |
| 92 | +{{ if $videoObject }}{{ $eventLD = merge $eventLD (dict "video" $videoObject) }}{{ end }} |
| 93 | + |
58 | 94 | {{ if $page_context.Params.author }}
|
59 | 95 | {{ $authorList := slice }}
|
60 | 96 | {{ with $page_context.Params.author }}{{ if reflect.IsSlice . }}{{ $authorList = . }}{{ else }}{{ $authorList = slice . }}{{ end }}{{ end }}
|
|
0 commit comments