cityuni-webserver/pageHandler/pages/index/about.go
Captain ALM fe6340e6df
All checks were successful
continuous-integration/drone/push Build is passing
Add about displaying support.
2022-07-26 13:39:26 +01:00

26 lines
663 B
Go

package index
import (
"html/template"
"strconv"
"strings"
"time"
)
type AboutYaml struct {
Title string `yaml:"title"`
Content string `yaml:"content"`
ThumbnailLocation string `yaml:"thumbnailLocation"`
ImageLocation string `yaml:"imageLocation"`
BirthYear int `yaml:"birthYear"`
ContactEmail string `yaml:"contactEmail"`
}
func (ay AboutYaml) GetContent() template.HTML {
return template.HTML(strings.ReplaceAll(strings.ReplaceAll(ay.Content, "#age#", strconv.Itoa(ay.GetAge())), "#birth#", strconv.Itoa(ay.BirthYear)))
}
func (ay AboutYaml) GetAge() int {
return time.Now().Year() - ay.BirthYear - 1
}