forked from jakub/jakubb-hugo
add calendar page layout as shortcode
This commit is contained in:
parent
9969b19f99
commit
6b221f66f5
@ -6,3 +6,6 @@ wend = "W"
|
|||||||
thurs = "Th"
|
thurs = "Th"
|
||||||
fri = "F"
|
fri = "F"
|
||||||
sat = "Sa"
|
sat = "Sa"
|
||||||
|
|
||||||
|
[dates]
|
||||||
|
far = "Further Events"
|
||||||
|
@ -6,3 +6,6 @@ wend = "Ś"
|
|||||||
thurs = "C"
|
thurs = "C"
|
||||||
fri = "Pi"
|
fri = "Pi"
|
||||||
sat = "S"
|
sat = "S"
|
||||||
|
|
||||||
|
[dates]
|
||||||
|
far = "Further Events"
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
{{ partial "header.html" . }}
|
{{ partial "header.html" . }}
|
||||||
{{ partial "nav.html" . }}
|
{{ partial "nav.html" . }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
{{ partial "footer.html" . }}
|
{{ partial "footer.html" . }}
|
||||||
|
198
layouts/shortcodes/cal_layout.html
Normal file
198
layouts/shortcodes/cal_layout.html
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
{{ $date := now }}
|
||||||
|
|
||||||
|
{{ $month := $date.Month | int }}
|
||||||
|
{{ $year := $date.Year }}
|
||||||
|
|
||||||
|
{{ $t1 := printf "%4d-%02d-01" $year $month }}
|
||||||
|
{{ $t1 := time.AsTime $t1 }}
|
||||||
|
{{ $t2 := $t1.AddDate 0 1 0 }}
|
||||||
|
|
||||||
|
{{ $daysInMonth := $t2.Sub $t1 }}
|
||||||
|
{{ $daysInMonth := $daysInMonth.Hours }}
|
||||||
|
{{ $daysInMonth := div $daysInMonth 24 }}
|
||||||
|
|
||||||
|
<div class="calendar">
|
||||||
|
<link rel="stylesheet" href="/css/calendar.css" type="text/css">
|
||||||
|
{{ if eq .Site.Language.Lang "pl" }}
|
||||||
|
{{ $polish_month_names := slice "Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień" }}
|
||||||
|
{{ $month := sub $month 1}}
|
||||||
|
{{ $label := index $polish_month_names $month }}
|
||||||
|
<a class="month">{{ printf "%s %d" $label $year }}</a>
|
||||||
|
{{ else }}
|
||||||
|
<a class="month">{{ time.Format "January 2006" $t1 }}</a>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<div class="weekdays" >
|
||||||
|
{{ $days := slice "sun" "mon" "tues" "wend" "thurs" "fri" "sat" }}
|
||||||
|
{{ range $days }}<p>{{ i18n (printf "days.%s" .) }}</p>{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="days">
|
||||||
|
{{ $padding := $t1.Weekday | int }}
|
||||||
|
{{ if gt $padding 0 }}
|
||||||
|
{{ range seq 1 $padding }}
|
||||||
|
<div class="pad-day"></div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range seq 1 $daysInMonth }}
|
||||||
|
<div class="day">
|
||||||
|
{{ $startDate := time.AsTime ( printf "%4d-%02d-%02dT00:00:00" $year $month . ) }}
|
||||||
|
{{ $endDate := time.AsTime ( printf "%4d-%02d-%02dT23:59:59" $year $month . ) }}
|
||||||
|
<h3 class="day-num">{{ . }}</h3>
|
||||||
|
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
|
||||||
|
|
||||||
|
{{ range where $.Site.RegularPages "Section" "eq" "events" }}
|
||||||
|
{{ $eventStart := time.AsTime .Params.start_date }}
|
||||||
|
{{ $eventEnd := time.AsTime .Params.end_date }}
|
||||||
|
|
||||||
|
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
|
||||||
|
<div class="event" >
|
||||||
|
<a href="{{ .RelPermalink }}">{{.Title}}</a>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{{ $date := $date.AddDate 0 1 0 }}
|
||||||
|
|
||||||
|
{{ $month := $date.Month | int }}
|
||||||
|
{{ $year := $date.Year }}
|
||||||
|
|
||||||
|
{{ $t1 := printf "%4d-%02d-01" $year $month }}
|
||||||
|
{{ $t1 := time.AsTime $t1 }}
|
||||||
|
{{ $t2 := $t1.AddDate 0 1 0 }}
|
||||||
|
|
||||||
|
{{ $daysInMonth := $t2.Sub $t1 }}
|
||||||
|
{{ $daysInMonth := $daysInMonth.Hours }}
|
||||||
|
{{ $daysInMonth := div $daysInMonth 24 }}
|
||||||
|
|
||||||
|
<div class="calendar">
|
||||||
|
<link rel="stylesheet" href="/css/calendar.css" type="text/css">
|
||||||
|
{{ if eq .Site.Language.Lang "pl" }}
|
||||||
|
{{ $polish_month_names := slice "Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień" }}
|
||||||
|
{{ $month := sub $month 1}}
|
||||||
|
{{ $label := index $polish_month_names $month }}
|
||||||
|
<a class="month">{{ printf "%s %d" $label $year }}</a>
|
||||||
|
{{ else }}
|
||||||
|
<a class="month">{{ time.Format "January 2006" $t1 }}</a>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<div class="weekdays" >
|
||||||
|
{{ $days := slice "sun" "mon" "tues" "wend" "thurs" "fri" "sat" }}
|
||||||
|
{{ range $days }}<p>{{ i18n (printf "days.%s" .) }}</p>{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="days">
|
||||||
|
{{ $padding := $t1.Weekday | int }}
|
||||||
|
{{ if gt $padding 0 }}
|
||||||
|
{{ range seq 1 $padding }}
|
||||||
|
<div class="pad-day"></div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range seq 1 $daysInMonth }}
|
||||||
|
<div class="day">
|
||||||
|
{{ $startDate := time.AsTime ( printf "%4d-%02d-%02dT00:00:00" $year $month . ) }}
|
||||||
|
{{ $endDate := time.AsTime ( printf "%4d-%02d-%02dT23:59:59" $year $month . ) }}
|
||||||
|
<h3 class="day-num">{{ . }}</h3>
|
||||||
|
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
|
||||||
|
|
||||||
|
{{ range where $.Site.RegularPages "Section" "eq" "events" }}
|
||||||
|
{{ $eventStart := time.AsTime .Params.start_date }}
|
||||||
|
{{ $eventEnd := time.AsTime .Params.end_date }}
|
||||||
|
|
||||||
|
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
|
||||||
|
<div class="event" >
|
||||||
|
<a href="{{ .RelPermalink }}">{{.Title}}</a>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ $date := $date.AddDate 0 1 0 }}
|
||||||
|
|
||||||
|
{{ $month := $date.Month | int }}
|
||||||
|
{{ $year := $date.Year }}
|
||||||
|
|
||||||
|
{{ $t1 := printf "%4d-%02d-01" $year $month }}
|
||||||
|
{{ $t1 := time.AsTime $t1 }}
|
||||||
|
{{ $t2 := $t1.AddDate 0 1 0 }}
|
||||||
|
|
||||||
|
{{ $daysInMonth := $t2.Sub $t1 }}
|
||||||
|
{{ $daysInMonth := $daysInMonth.Hours }}
|
||||||
|
{{ $daysInMonth := div $daysInMonth 24 }}
|
||||||
|
|
||||||
|
<div class="calendar">
|
||||||
|
<link rel="stylesheet" href="/css/calendar.css" type="text/css">
|
||||||
|
{{ if eq .Site.Language.Lang "pl" }}
|
||||||
|
{{ $polish_month_names := slice "Styczeń" "Luty" "Marzec" "Kwiecień" "Maj" "Czerwiec" "Lipiec" "Sierpień" "Wrzesień" "Październik" "Listopad" "Grudzień" }}
|
||||||
|
{{ $month := sub $month 1}}
|
||||||
|
{{ $label := index $polish_month_names $month }}
|
||||||
|
<a class="month">{{ printf "%s %d" $label $year }}</a>
|
||||||
|
{{ else }}
|
||||||
|
<a class="month">{{ time.Format "January 2006" $t1 }}</a>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<div class="weekdays" >
|
||||||
|
{{ $days := slice "sun" "mon" "tues" "wend" "thurs" "fri" "sat" }}
|
||||||
|
{{ range $days }}<p>{{ i18n (printf "days.%s" .) }}</p>{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="days">
|
||||||
|
{{ $padding := $t1.Weekday | int }}
|
||||||
|
{{ if gt $padding 0 }}
|
||||||
|
{{ range seq 1 $padding }}
|
||||||
|
<div class="pad-day"></div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range seq 1 $daysInMonth }}
|
||||||
|
<div class="day">
|
||||||
|
{{ $startDate := time.AsTime ( printf "%4d-%02d-%02dT00:00:00" $year $month . ) }}
|
||||||
|
{{ $endDate := time.AsTime ( printf "%4d-%02d-%02dT23:59:59" $year $month . ) }}
|
||||||
|
<h3 class="day-num">{{ . }}</h3>
|
||||||
|
<h3 class="mobile-date">{{ $startDate | time.Format ":date_long" }} </h3>
|
||||||
|
|
||||||
|
{{ range where $.Site.RegularPages "Section" "eq" "events" }}
|
||||||
|
{{ $eventStart := time.AsTime .Params.start_date }}
|
||||||
|
{{ $eventEnd := time.AsTime .Params.end_date }}
|
||||||
|
|
||||||
|
{{ if and ( or ($eventEnd.After $startDate) ($eventEnd.Equal $startDate)) (or ( $eventStart.Before $endDate ) ( $eventStart.Equal $endDate )) }}
|
||||||
|
<div class="event" >
|
||||||
|
<a href="{{ .RelPermalink }}">{{.Title}}</a>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>{{ i18n "dates.far" }}</h2>
|
||||||
|
{{ $startDate := now }}
|
||||||
|
{{ $month := $startDate.Month | int }}
|
||||||
|
{{ $year := $startDate.Year }}
|
||||||
|
{{ $startDate := printf "%4d-%02d-01" $year $month }}
|
||||||
|
{{ $startDate := time.AsTime $startDate }}
|
||||||
|
{{ $startDate := $startDate.AddDate 0 3 0 }}
|
||||||
|
|
||||||
|
{{ $endDate := $startDate.AddDate 0 6 0 }}
|
||||||
|
<ul>
|
||||||
|
{{ range sort (where .Site.RegularPages "Section" "events") "Params.start_date" "asc" }}
|
||||||
|
{{ $eventDate := time.AsTime .Params.start_date }}
|
||||||
|
{{ if and ( or ($eventDate.After $startDate) ($eventDate.Equal $startDate)) ($eventDate.Before $endDate) }}
|
||||||
|
<li>{{$eventDate.Format "Jan 2, 2006" }} - <a href="{{ .RelPermalink }}">{{.Title}}</a></li>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user