Render all months in sidebar

This commit is contained in:
2026-07-01 11:00:41 +02:00
parent ecaf3f4e12
commit 8c9b448bdc
4 changed files with 59 additions and 78 deletions
+12 -16
View File
@@ -343,8 +343,8 @@ type calYear struct {
}
// calMonthGrid carries everything the template needs to render one month's
// grid plus the dropdown / heading entry that targets it. The calendar
// widget ships all 12 in the initial HTML; JS swaps which one is visible.
// grid plus the caption that links to it. The calendar widget renders all 12
// stacked vertically; JS centers the current month in the rail on load.
type calMonthGrid struct {
Num int
Name string
@@ -353,13 +353,11 @@ type calMonthGrid struct {
}
type calendarData struct {
DisplayYear int
DisplayMonth int
DisplayMonthName string // pre-resolved so the template doesn't need arithmetic
DiaryURL string
YearURL string
Months []calMonthGrid
Years []calYear
DisplayYear int
DisplayMonth int
DiaryURL string
Months []calMonthGrid
Years []calYear
}
var diaryCalTmpl = template.Must(template.ParseFS(assets, "assets/diary/calendar.html"))
@@ -489,13 +487,11 @@ func computeCalendarWidget(diaryRootFS, diaryRootURL, fsPath string, depth int)
sort.Slice(years, func(i, j int) bool { return years[i].Num > years[j].Num })
data := calendarData{
DisplayYear: displayYear,
DisplayMonth: displayMonth,
DisplayMonthName: months[displayMonth-1].Name,
DiaryURL: diaryRootURL,
YearURL: yearURL,
Months: months,
Years: years,
DisplayYear: displayYear,
DisplayMonth: displayMonth,
DiaryURL: diaryRootURL,
Months: months,
Years: years,
}
var buf bytes.Buffer