mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-11 12:11:45 +00:00
refactor(events): namespace front matter to avoid conflict with Hugo's date
BREAKING CHANGE: Standardize event metadata by introducing event_start, event_end, event_all_day, and event_name, keep Hugo’s built-in date for publication, and update all layouts/partials/JSON-LD/views to read the new names; demo event content now reflects the renamed params so event listings show their true schedule instead of the page creation date.
This commit is contained in:
1 parent
d1b9c1ffb8
commit
0e60ce6608
8 files changed
+47
-27
No files matched your search
@@ -1,17 +1,21 @@
|
||||
{{/* Function to get event start and end dates/times. */}}
|
||||
{{ $t1 := time .Date }}{{/* Start datetime. */}}
|
||||
{{ $start_date := .Params.event_start | default .Date }}
|
||||
{{ $end_date := .Params.event_end | default .Params.date_end }}
|
||||
{{ $all_day := .Params.event_all_day | default .Params.all_day }}
|
||||
|
||||
{{ $t1 := time $start_date }}{{/* Start datetime. */}}
|
||||
{{ $str := slice (time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") (time $t1)) }}{{/* Init return string with start date. */}}
|
||||
{{/* Show start time if not all day event. */}}
|
||||
{{ if not .Params.all_day }}{{ $str = $str | append (time.Format (site.Params.hugoblox.locale.time_format | default "3:04 PM") (time $t1)) }}{{ end }}
|
||||
{{ if not $all_day }}{{ $str = $str | append (time.Format (site.Params.hugoblox.locale.time_format | default "3:04 PM") (time $t1)) }}{{ end }}
|
||||
{{/* Show event end date if provided. */}}
|
||||
{{ if .Params.date_end }}
|
||||
{{ if $end_date }}
|
||||
{{ $str = $str | append "—" }}
|
||||
{{ $t2 := time .Params.date_end}}{{/* End datetime. */}}
|
||||
{{ $t2 := time $end_date}}{{/* End datetime. */}}
|
||||
{{/* Show end date if it differs to start date. */}}
|
||||
{{ if not (eq $t1.Year $t2.Year | and (eq $t1.Month $t2.Month) | and (eq $t1.Day $t2.Day)) }}
|
||||
{{ $str = $str | append (time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") (time $t2)) }}
|
||||
{{ end }}
|
||||
{{/* Show end time if not all day event. */}}
|
||||
{{ if not .Params.all_day }}{{ $str = $str | append (time.Format (site.Params.hugoblox.locale.time_format | default "3:04 PM") (time $t2)) }}{{ end }}
|
||||
{{ if not $all_day }}{{ $str = $str | append (time.Format (site.Params.hugoblox.locale.time_format | default "3:04 PM") (time $t2)) }}{{ end }}
|
||||
{{ end }}
|
||||
{{ return ((delimit $str " ") | safeHTML) }}
|
||||
@@ -32,8 +32,9 @@
|
||||
{{$featured_image.Permalink}}
|
||||
],
|
||||
{{end}}
|
||||
"startDate": {{ $page.Date.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{with $page.Params.date_end}}
|
||||
{{ $start := $page.Params.event_start | default $page.Date }}
|
||||
"startDate": {{ (time $start).Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{with ($page.Params.event_end | default $page.Params.date_end)}}
|
||||
"endDate": {{ (time .).Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{end}}
|
||||
{{with $author}}
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
{{ $showReadMore := .config.show_read_more | default true }}
|
||||
{{ $hasMeta := or $showDate $showReadTime $showReadMore }}
|
||||
{{ $index := .index }}
|
||||
{{ $isEvent := eq $item.Type "events" }}
|
||||
{{ $event_dates := "" }}
|
||||
{{ if $isEvent }}
|
||||
{{ $event_dates = partial "functions/get_event_dates" $item }}
|
||||
{{ end }}
|
||||
|
||||
<div class="group bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-2xl ring-1 ring-zinc-900/5 dark:ring-white/10 shadow-lg overflow-hidden transition-all duration-300 ease-out hover:shadow-xl hover:shadow-blue-500/10 hover:-translate-y-2 focus-within:ring-2 focus-within:ring-blue-500/50" role="article" aria-labelledby="card-title-{{ $item.File.UniqueID }}">
|
||||
<!-- Image Section -->
|
||||
@@ -166,9 +171,13 @@
|
||||
<span class="opacity-40">•</span>
|
||||
{{ end }}
|
||||
{{ if $showDate }}
|
||||
{{ if $isEvent }}
|
||||
<span class="hidden sm:inline whitespace-nowrap">{{ $event_dates }}</span>
|
||||
{{ else }}
|
||||
<time class="hidden sm:inline whitespace-nowrap" datetime="{{ $item.Date.Format "2006-01-02" }}">
|
||||
{{ $item.Date | time.Format (site.Params.hugoblox.locale.date_format | default "Jan 2, 2006") }}
|
||||
</time>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if and $showDate $showReadTime }}
|
||||
<span class="hidden sm:inline opacity-40">•</span>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{{ $item := .item }}
|
||||
{{ $year_value := $item.Params.event_start | default $item.Date }}
|
||||
{{ $year := (time $year_value).Format "2006" }}
|
||||
{{ $has_attachments := partial "functions/has_attachments" $item }}
|
||||
|
||||
<div class="pub-list-item view-citation" style="margin-bottom: 1rem">
|
||||
@@ -10,7 +12,7 @@
|
||||
<span class="article-metadata li-cite-author">
|
||||
{{ partial "page_metadata_authors" $item }}
|
||||
</span>
|
||||
({{- $item.Date.Format "2006" -}}).
|
||||
({{- $year -}}).
|
||||
<a href="{{ $item.RelPermalink }}" class="underline">{{ $item.Title }}</a>.
|
||||
{{ if $item.Params.publication_short }}
|
||||
{{- $item.Params.publication_short | markdownify -}}.
|
||||
@@ -36,7 +38,7 @@
|
||||
{{ else if $item.Params.publication }}
|
||||
{{- $item.Params.publication | markdownify -}},
|
||||
{{ end }}
|
||||
{{- $item.Date.Format "2006" -}}.
|
||||
{{- $year -}}.
|
||||
|
||||
{{ if $has_attachments }}
|
||||
<div class="flex flex-wrap space-x-3">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{{ $page := .page }}
|
||||
{{ $summary := partial "functions/get_summary" $item }}
|
||||
{{ $summary = $summary | page.RenderString }}
|
||||
{{ $displayDate := .item.Params.event_start | default .item.Date }}
|
||||
<article class="md:grid md:grid-cols-4 md:items-baseline">
|
||||
<div class="md:col-span-3 group relative flex flex-col items-start">
|
||||
<h2 class="text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-100">
|
||||
@@ -12,8 +13,8 @@
|
||||
</h2>
|
||||
<time
|
||||
class="md:hidden relative z-10 order-first mb-3 flex items-center text-sm text-zinc-400 dark:text-zinc-500 pl-1"
|
||||
datetime="{{ time.Format "2006-01-02" $item.Date }}">
|
||||
{{ time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") $item.Date }}
|
||||
datetime="{{ time.Format "2006-01-02" $displayDate }}">
|
||||
{{ time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") $displayDate }}
|
||||
</time>
|
||||
<p class="relative z-10 mt-2 text-sm text-zinc-600 dark:text-zinc-400 line-clamp-3">{{$summary}}</p>
|
||||
<div aria-hidden="true" class="relative z-10 mt-4 flex items-center text-sm font-medium text-primary-500">
|
||||
@@ -25,6 +26,6 @@
|
||||
</div>
|
||||
<time
|
||||
class="mt-1 hidden md:block relative z-10 order-first mb-3 flex items-center text-sm text-zinc-400 dark:text-zinc-500"
|
||||
datetime="{{ time.Format "2006-01-02" $item.Date }}">{{ time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") $item.Date }}
|
||||
datetime="{{ time.Format "2006-01-02" $displayDate }}">{{ time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") $displayDate }}
|
||||
</time>
|
||||
</article>
|
||||
@@ -56,10 +56,11 @@
|
||||
{{ end }}
|
||||
</h1>
|
||||
|
||||
{{ $display_date := .Params.event_start | default .Date }}
|
||||
<div class="mt-4 mb-16">
|
||||
<div class="text-gray-500 dark:text-gray-300 text-sm flex items-center flex-wrap gap-y-2">
|
||||
{{- if .Date | and (not .Params.hide_date) -}}
|
||||
<span class="mr-1">{{- .Date | time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") -}}</span>
|
||||
{{- if $display_date | and (not .Params.hide_date) -}}
|
||||
<span class="mr-1">{{- (time $display_date) | time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") -}}</span>
|
||||
{{- if .Params.authors }}<span class="mx-1">·</span>{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -353,11 +354,11 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.event }}
|
||||
{{ if .Params.event_name }}
|
||||
<div class="font-bold text-2xl">{{ i18n "event" }}</div>
|
||||
<div>
|
||||
{{ with .Params.event_url }}<a href="{{ . }}" target="_blank" rel="noopener">{{ end }}
|
||||
{{ .Params.event | markdownify }}
|
||||
{{ .Params.event_name | markdownify }}
|
||||
{{ if .Params.event_url }}</a>{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -65,10 +65,11 @@
|
||||
{{ end }}
|
||||
</h1>
|
||||
|
||||
{{ $display_date := .Params.event_start | default .Date }}
|
||||
<div class="mt-4 mb-16">
|
||||
<div class="text-gray-500 dark:text-gray-300 text-sm flex items-center flex-wrap gap-y-2">
|
||||
{{- if .Date | and (not .Params.hide_date) -}}
|
||||
<span class="mr-1">{{- .Date | time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") -}}</span>
|
||||
{{- if $display_date | and (not .Params.hide_date) -}}
|
||||
<span class="mr-1">{{- (time $display_date) | time.Format (site.Params.hugoblox.locale.date_format | default ":date_long") -}}</span>
|
||||
{{- if .Params.authors }}<span class="mx-1">·</span>{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -268,11 +269,11 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.event }}
|
||||
{{ if .Params.event_name }}
|
||||
<div class="font-bold text-2xl">{{ i18n "event" }}</div>
|
||||
<div>
|
||||
{{ with .Params.event_url }}<a href="{{ . }}" target="_blank" rel="noopener">{{ end }}
|
||||
{{ .Params.event | markdownify }}
|
||||
{{ .Params.event_name | markdownify }}
|
||||
{{ if .Params.event_url }}</a>{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
Reference in new issue
Block a user