package articles import ( "html/template" "phc/website/services/server/dev" "phc/website/services/server/router" "phc/website/sl" ) func Configure(l *sl.ServiceLocator) error { router.UseRouteTemplatedPage(l, "/articles", "pages/articles/index.html", func(w dev.ResponseWriter, r dev.Request) error { tmpl := template.New("") tmpl, err := tmpl.Parse(string(r.Page())) if err != nil { return err } ctx := map[string]any{ "Example": "Bla bla", } if err := tmpl.Execute(w, ctx); err != nil { return err } return nil }, ) router.UseRouteTemplatedPage(l, "/articles/:slug", "pages/articles/article.html", func(w dev.ResponseWriter, r dev.Request) error { tmpl := template.New("") tmpl, err := tmpl.Parse(string(r.Page())) if err != nil { return err } ctx := map[string]any{ "Title": r.Param("slug"), "Example": "Bla bla " + r.Param("slug"), } if err := tmpl.Execute(w, ctx); err != nil { return err } return nil }, ) return nil }