Added static pages

This commit is contained in:
Simon Martens
2024-12-03 20:15:39 +01:00
parent 71927afebd
commit 5f6886a144
17 changed files with 72 additions and 30 deletions

7
viewmodels/page.go Normal file
View File

@@ -0,0 +1,7 @@
package viewmodels
type PageViewModel struct {
Title string
Description string
Keywords string
}

View File

@@ -45,11 +45,16 @@ func YearView(year string, lib *xmlprovider.Library) (*YearViewModel, error) {
return nil, errors.New("No issues found for year " + year)
}
res.SortAvailableYears()
res.Sort()
return &res, nil
}
func (y *YearViewModel) Sort() {
y.SortAvailableYears()
y.Issues.Sort()
}
func (y *YearViewModel) PushIssue(i xmlprovider.Issue) {
iv, err := FromIssue(i)
if err != nil {
@@ -59,6 +64,12 @@ func (y *YearViewModel) PushIssue(i xmlprovider.Issue) {
list, ok := y.Issues[iv.Month]
if !ok {
list = []IssueViewModel{}
} else {
for _, issue := range list {
if issue.Number.No == iv.Number.No {
return
}
}
}
y.Issues[iv.Month] = append(list, *iv)
@@ -84,3 +95,11 @@ func (y *YearViewModel) SortAvailableYears() {
return iint < jint
})
}
func (ibm *IssuesByMonth) Sort() {
for _, issues := range *ibm {
sort.Slice(issues, func(i, j int) bool {
return issues[i].Number.No < issues[j].Number.No
})
}
}