2022-07-16 22:20:56 +01:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
2022-07-26 13:39:26 +01:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2022-07-16 22:20:56 +01:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AboutYaml struct {
|
|
|
|
Title string `yaml:"title"`
|
|
|
|
Content string `yaml:"content"`
|
|
|
|
ThumbnailLocation string `yaml:"thumbnailLocation"`
|
|
|
|
ImageLocation string `yaml:"imageLocation"`
|
2022-07-26 23:51:27 +01:00
|
|
|
ImageAltText string `yaml:"imageAltText"`
|
2022-07-16 22:20:56 +01:00
|
|
|
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)))
|
2022-07-16 22:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ay AboutYaml) GetAge() int {
|
|
|
|
return time.Now().Year() - ay.BirthYear - 1
|
|
|
|
}
|