From 2f1228da9a51a5c887b6194e20d99b105fbbbdab Mon Sep 17 00:00:00 2001 From: Jakub Date: Wed, 14 Feb 2024 00:25:55 -0500 Subject: [PATCH] work on cal shorcode - now only needs a date, will auto calc pad days and month length --- layouts/shortcodes/calendar.html | 44 +++++++++++++++++--------------- static/css/style.css | 5 ++-- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/layouts/shortcodes/calendar.html b/layouts/shortcodes/calendar.html index e11f3bc..76d611e 100644 --- a/layouts/shortcodes/calendar.html +++ b/layouts/shortcodes/calendar.html @@ -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 }}
- {{ time.Format "January 2006" "01 Dec 2024" }} + {{ 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 }}
- {{ $padding := 4 }} - {{ range seq 1 1}} -
- {{ end }} + {{ if gt $padding 0 }} + {{ range seq 1 $padding }} +
+ {{ end }} + {{ end }} + {{ range seq 1 $daysInMonth }}
{{ . }}
{{ end }} @@ -31,10 +33,12 @@
+ \ No newline at end of file + diff --git a/static/css/style.css b/static/css/style.css index e54a54e..5554cd3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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 */