Remove KCD UK

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
2024-10-27 13:45:15 +00:00
parent b9981f35ea
commit 5b0c85711f
2 changed files with 15 additions and 7 deletions

15
main.go
View File

@@ -9,6 +9,7 @@ import (
"os"
"path"
"strings"
"time"
"gopkg.in/yaml.v2"
)
@@ -36,6 +37,8 @@ func main() {
panic(err)
}
// Set up "slugs" that can be used as redirects to social media accounts
// E.g. https://marcusnoble.com/mastodon -> https://k8s.social/@Marcus
for _, l := range data["social"].([]interface{}) {
link := l.(map[interface{}]interface{})
if link["slug"] != "" {
@@ -43,6 +46,18 @@ func main() {
}
}
// Filter out any events that have passed already
futureEvents := []map[interface{}]interface{}{}
dateLayout := "2006-01-02"
for _, e := range data["events"].([]interface{}) {
event := e.(map[interface{}]interface{})
t, err := time.Parse(dateLayout, event["date"].(string))
if err == nil && time.Now().Before(t) {
futureEvents = append(futureEvents, event)
}
}
data["events"] = futureEvents
funcMap := template.FuncMap(map[string]interface{}{
"join": func(objs []interface{}, key, joiner string) template.HTML {
vals := []string{}