From e5d1c25bbf5afcc6379d4670015a2f2d2d99ee45 Mon Sep 17 00:00:00 2001 From: Kirill Zhuravlev Date: Tue, 14 Feb 2023 22:59:11 +0100 Subject: [PATCH] simplify template context --- scripts.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts.go b/scripts.go index a7162811..30726e1e 100644 --- a/scripts.go +++ b/scripts.go @@ -8,10 +8,6 @@ import ( "github.com/avelino/awesome-go/pkg/markdown" ) -type content struct { - Body template.HTML -} - // ConvertAndRenderIndex generate site html (index.html) from markdown file func ConvertAndRenderIndex(srcFilename, outFilename string) error { input, err := os.ReadFile(srcFilename) @@ -24,14 +20,16 @@ func ConvertAndRenderIndex(srcFilename, outFilename string) error { return err } - c := &content{Body: template.HTML(body)} f, err := os.Create(outFilename) if err != nil { return err } fmt.Printf("Write Index file: %s\n", outIndexFile) - if err := tplIndex.Execute(f, c); err != nil { + data := map[string]interface{}{ + "Body": template.HTML(body), + } + if err := tplIndex.Execute(f, data); err != nil { return err }