Add Table of Contents
also refactor CSS
This commit is contained in:
@@ -69,12 +69,14 @@ type diaryPhoto struct {
|
||||
}
|
||||
|
||||
type diaryMonthSummary struct {
|
||||
ID string
|
||||
Name string
|
||||
URL string
|
||||
PhotoCount int
|
||||
}
|
||||
|
||||
type diaryDaySection struct {
|
||||
ID string
|
||||
Heading string
|
||||
URL string
|
||||
EditURL string
|
||||
@@ -82,7 +84,10 @@ type diaryDaySection struct {
|
||||
Photos []diaryPhoto
|
||||
}
|
||||
|
||||
type diaryYearData struct{ Months []diaryMonthSummary }
|
||||
type diaryYearData struct {
|
||||
Months []diaryMonthSummary
|
||||
Year int
|
||||
}
|
||||
type diaryMonthData struct{ Days []diaryDaySection }
|
||||
type diaryDayData struct{ Photos []diaryPhoto }
|
||||
|
||||
@@ -191,6 +196,7 @@ func renderDiaryYear(fsPath, urlPath string) template.HTML {
|
||||
}
|
||||
monthDate := time.Date(year, time.Month(monthNum), 1, 0, 0, 0, 0, time.UTC)
|
||||
months = append(months, diaryMonthSummary{
|
||||
ID: monthDate.Format("2006-01"),
|
||||
Name: monthDate.Format("January 2006"),
|
||||
URL: path.Join(urlPath, e.Name()) + "/",
|
||||
PhotoCount: count,
|
||||
@@ -198,7 +204,7 @@ func renderDiaryYear(fsPath, urlPath string) template.HTML {
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := diaryYearTmpl.Execute(&buf, diaryYearData{Months: months}); err != nil {
|
||||
if err := diaryYearTmpl.Execute(&buf, diaryYearData{Months: months, Year: year}); err != nil {
|
||||
log.Printf("diary year template: %v", err)
|
||||
return ""
|
||||
}
|
||||
@@ -280,6 +286,7 @@ func renderDiaryMonth(fsPath, urlPath string) template.HTML {
|
||||
}
|
||||
|
||||
sections = append(sections, diaryDaySection{
|
||||
ID: date.Format("2006-01-02"),
|
||||
Heading: heading,
|
||||
URL: dayURL,
|
||||
EditURL: dayURL + "?edit",
|
||||
|
||||
Reference in New Issue
Block a user