cityuni-webserver/pageHandler/pages/index/about.go

27 lines
753 B
Go
Raw Normal View History

package index
import (
"html/template"
2022-07-26 13:39:26 +01:00
"strconv"
"strings"
"time"
)
type AboutYaml struct {
2022-07-27 01:16:37 +01:00
Title string `yaml:"title"`
Content string `yaml:"content"`
ThumbnailLocation template.URL `yaml:"thumbnailLocation"`
ImageLocation template.URL `yaml:"imageLocation"`
ImageAltText string `yaml:"imageAltText"`
BirthYear int `yaml:"birthYear"`
ContactEmail string `yaml:"contactEmail"`
}
func (ay AboutYaml) GetContent() template.HTML {
2022-07-26 13:39:26 +01:00
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
}