forked from jakub/jakubb-hugo
work on cal shorcode - now only needs a date, will auto calc pad days and month length
This commit is contained in:
parent
c2532014be
commit
2f1228da9a
@ -1,29 +1,31 @@
|
||||
{{ $month := .Get "month" }}
|
||||
{{ if not $month }}
|
||||
{{ errorf "Error: 'month' is a required parameter." }}
|
||||
{{ $date:= .Get "date" }}
|
||||
{{ if not $date }}
|
||||
{{ errorf "Error: 'date' is a required parameter." }}
|
||||
{{ end }}
|
||||
{{ $date := time.AsTime $date }}
|
||||
|
||||
{{ $year := .Get "year" }}
|
||||
{{ if not $year }}
|
||||
{{ errorf "Error: 'year' is a required parameter." }}
|
||||
{{ end }}
|
||||
{{ $month := $date.Month | int }}
|
||||
{{ $year := $date.Year }}
|
||||
|
||||
{{ $label := .Get "label" }}
|
||||
{{ if not $label }}
|
||||
{{ errorf "Error: 'label' is a required parameter." }}
|
||||
{{ end }}
|
||||
{{ $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 }}
|
||||
|
||||
{{ $daysInMonth := 27 }}
|
||||
|
||||
{{ $padding := $t1.Weekday | int }}
|
||||
|
||||
<div class="calendar">
|
||||
<a class="month">{{ time.Format "January 2006" "01 Dec 2024" }}</a>
|
||||
<a class="month">{{ 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 }}{{ printf "%s %d" $label $year }}{{ else }}{{ time.Format "January 2006" $t1 }}{{ end }}</a>
|
||||
<div class="days">
|
||||
{{ $padding := 4 }}
|
||||
{{ range seq 1 1}}
|
||||
<div class="pad-day"></div>
|
||||
{{ end }}
|
||||
{{ if gt $padding 0 }}
|
||||
{{ range seq 1 $padding }}
|
||||
<div class="pad-day"></div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ range seq 1 $daysInMonth }}
|
||||
<div class="day">{{ . }}</div>
|
||||
{{ end }}
|
||||
@ -31,10 +33,12 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
.calendar {
|
||||
width: 100%;
|
||||
margin: 20px 0;
|
||||
max-width: 1000px;
|
||||
margin: 20px auto;
|
||||
padding: 0;
|
||||
background-color: darkslategray;
|
||||
}
|
||||
@ -77,4 +81,4 @@
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
@ -118,8 +118,9 @@ a.home-link { display: none; }
|
||||
.menu-btn:checked ~ .menu .menu-entries {
|
||||
/* Reveal Entries */
|
||||
height: auto;
|
||||
max-height: 900px; /* May Need to be change manually for nav lists */
|
||||
}
|
||||
max-height: 75%; /* May Need to be change manually for nav lists */
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.menu-btn:checked ~ .menu .logo, .menu-entries a:hover {
|
||||
/* BG Color on logo an hover effect */
|
||||
|
Loading…
Reference in New Issue
Block a user