Skip to content

Commit

Permalink
Ajout d'un partiel pour la date des événements (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisben authored Nov 15, 2024
1 parent f73e5a2 commit 592c243
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
38 changes: 38 additions & 0 deletions layouts/partials/events/event-schedule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{ $dates := .dates }}
{{ $layout := .layout }}
{{ if or $dates.computed.short $dates.computed.two_lines.short $dates.from.hour $dates.to.hour }}
<div class="event-schedule" itemprop="startDate" content="{{- if $dates.from.day -}}{{ $dates.from.day }}{{- end -}}{{- if $dates.from.hour -}}T{{ $dates.from.hour }}{{- end -}}">
<p class="event-dates">
{{ $formated_date := $dates.computed.two_lines.short }}
{{ if ne $layout "list" }}
{{ $formated_date = $dates.computed.short }}
{{ end }}
{{ with site.Params.events.date_format }}
{{ $formated_date = time.Format . $dates.from.day }}
{{ if ne $dates.from.day $dates.to.day }}
{{ $formated_date = printf "<span>%s</span><span>%s</span>" $formated_date ( time.Format . $dates.to.day ) }}
{{ end }}
{{ end }}
{{ partial "PrepareHTML" $formated_date }}
</p>
{{- if (or $dates.from.hour $dates.to.hour) }}
{{- $hour := "" -}}
<p class="event-time">
{{ with $dates.from.hour }}
{{- $hour = . -}}
{{- with site.Params.events.time_format }}
{{- $hour = time.Format . (printf "2021-09-01T%s:00" $hour) -}}
{{ end -}}
<span>{{- $hour -}}</span>
{{- end -}}
{{- with $dates.to.hour -}}
{{- $hour = . -}}
{{- with site.Params.events.time_format -}}
{{- $hour = time.Format . (printf "2021-09-01T%s:00" $hour) -}}
{{- end -}}
<span>{{- $hour -}}</span>
{{ end -}}
</p>
{{ end -}}
</div>
{{ end }}
41 changes: 6 additions & 35 deletions layouts/partials/events/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,13 @@
{{ end }}

{{ $dates := .Params.dates }}
{{ if and $options.dates (or $dates.computed.short $dates.computed.two_lines.short $dates.from.hour $dates.to.hour) }}
<div class="event-schedule" itemprop="startDate" content="{{- if $dates.from.day -}}{{ $dates.from.day }}{{- end -}}{{- if $dates.from.hour -}}T{{ $dates.from.hour }}{{- end -}}">
<p class="event-dates">
{{ $formated_date := $dates.computed.two_lines.short }}
{{ if ne $layout "list" }}
{{ $formated_date = $dates.computed.short }}
{{ end }}
{{ with site.Params.events.date_format }}
{{ $formated_date = time.Format . $dates.from.day }}
{{ if ne $dates.from.day $dates.to.day }}
{{ $formated_date = printf "<span>%s</span><span>%s</span>" $formated_date ( time.Format . $dates.to.day ) }}
{{ end }}
{{ end }}
{{ partial "PrepareHTML" $formated_date }}
</p>
{{- if (or $dates.from.hour $dates.to.hour) }}
{{- $hour := "" -}}
<p class="event-time">
{{ with $dates.from.hour }}
{{- $hour = . -}}
{{- with site.Params.events.time_format }}
{{- $hour = time.Format . (printf "2021-09-01T%s:00" $hour) -}}
{{ end -}}
<span>{{- $hour -}}</span>
{{- end -}}
{{- with $dates.to.hour -}}
{{- $hour = . -}}
{{- with site.Params.events.time_format -}}
{{- $hour = time.Format . (printf "2021-09-01T%s:00" $hour) -}}
{{- end -}}
<span>{{- $hour -}}</span>
{{ end -}}
</p>
{{ end -}}
</div>
{{ if $options.dates }}
{{ partial "events/event-schedule" (dict
"dates" $dates
"layout" $layout
)}}
{{ end }}

{{ if and $dates.status $options.status }}
<p class="event-status">
{{ if eq $dates.status "current"}}
Expand Down

0 comments on commit 592c243

Please sign in to comment.