Update content variable support.

This commit is contained in:
Captain ALM 2025-01-15 15:38:36 +00:00
parent 51487c66c9
commit 8b4bdf625f
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
2 changed files with 3 additions and 2 deletions

View File

@ -56,7 +56,7 @@ about:
Here is my <a href="https://cdn.captainalm.com/download/keys/alfred@captainalm.com.asc">GPG Key</a> for my email address.
</p>
<p>
My CV is available in the following formats: ( <a href="https://cdn.captainalm.com/download/cvs/AlfredManvilleCV-2025.docx">DOCX</a> | <a href="https://cdn.captainalm.com/download/cvs/AlfredManvilleCV-2025.pdf">PDF</a> )
My CV is available in the following formats: ( <a href="https://cdn.captainalm.com/download/cvs/AlfredManvilleCV-#year#.docx">DOCX</a> | <a href="https://cdn.captainalm.com/download/cvs/AlfredManvilleCV-#year#.pdf">PDF</a> )
</p>
thumbnailLocation: "resources/assets/imageofyou_t.jpg"
imageLocation: "resources/assets/imageofyou.jpg"

View File

@ -18,7 +18,8 @@ type AboutYaml struct {
}
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)))
r := strings.NewReplacer("#age#", strconv.Itoa(ay.GetAge()), "#birth#", strconv.Itoa(ay.BirthYear), "#year#", strconv.Itoa(time.Now().Year()))
return template.HTML(r.Replace(ay.Content))
}
func (ay AboutYaml) GetAge() int {