From 5b0c85711f474312581ec404edc65b5c2a3a221c Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sun, 27 Oct 2024 13:45:15 +0000 Subject: [PATCH] Remove KCD UK Signed-off-by: Marcus Noble --- data.yaml | 7 ------- main.go | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/data.yaml b/data.yaml index 664dc8a..cf3e6ae 100644 --- a/data.yaml +++ b/data.yaml @@ -139,13 +139,6 @@ badges: url: https://www.credly.com/badges/cd63e887-72ac-49b0-8322-a4062d86d997/public_url events: - - date: "2024-10-22" - humanDate: "October 22nd - 23rd, 2024" - url: https://community.cncf.io/events/details/cncf-kcd-uk-presents-kubernetes-community-days-uk-london-2024/ - eventName: Kubernetes Community Days UK - details: - - name: "From Fragile to Resilient: Using Admission Policies to Strengthen Kubernetes" - type: Talk - date: "2024-11-10" humanDate: "November 10th - 11th, 2024" url: https://cloud-native.rejekts.io/ diff --git a/main.go b/main.go index ee07152..0acc4e9 100644 --- a/main.go +++ b/main.go @@ -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{}