From a7d5246c0c02af9c34d6a094b0378fa3d02d8bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?n=CE=B9c=D0=BDola=D1=95=20w=CE=B9lde?= Date: Sat, 16 Jul 2022 02:14:27 +0000 Subject: [PATCH 1/2] fix: format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nιcнolaѕ wιlde --- pkg/document/template.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/document/template.go b/pkg/document/template.go index 0522f30..a304943 100644 --- a/pkg/document/template.go +++ b/pkg/document/template.go @@ -4,11 +4,11 @@ import ( "errors" "fmt" "io/ioutil" + "net/url" "os" "path/filepath" "strings" "text/template" - "net/url" "github.com/Masterminds/sprig/v3" "github.com/aquilax/cooklang-go" @@ -323,14 +323,14 @@ func newRecipeDocumentationTemplate(recipeSearchRoot string, recipeInfo cook.Rec documentationTemplate := template.New(recipeInfo.RecipePath) documentationTemplate.Funcs(sprig.TxtFuncMap()) documentationTemplate.Funcs(template.FuncMap{"getSource": func(source string) string { - _, err := url.ParseRequestURI(source) + _, err := url.ParseRequestURI(source) if err != nil { return source } u, err := url.Parse(source) if err != nil || u.Scheme == "" || u.Host == "" { return source - } + } return "<" + source + ">" }}) documentationTemplate.Funcs(template.FuncMap{"sumTimers": func(steps []cooklang.Step) string { From bb16cce672c77f6b354f766a5f19d11cd84fea2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?n=CE=B9c=D0=BDola=D1=95=20w=CE=B9lde?= Date: Sat, 16 Jul 2022 02:15:08 +0000 Subject: [PATCH 2/2] fix: don't set ImageName if ImagePath is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nιcнolaѕ wιlde --- pkg/cook/recipe_info.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cook/recipe_info.go b/pkg/cook/recipe_info.go index d7d5c13..b05ce04 100644 --- a/pkg/cook/recipe_info.go +++ b/pkg/cook/recipe_info.go @@ -67,7 +67,9 @@ func MergeRecipeData(recipeInfo RecipeDocumentationInfo, recipeData *cooklang.Re recipeData.Metadata["title"] = recipeInfo.RecipeName - recipeData.Metadata["ImageName"] = filepath.Base(recipeInfo.ImagePath) + if len(recipeInfo.ImagePath) > 0 { + recipeData.Metadata["ImageName"] = filepath.Base(recipeInfo.ImagePath) + } return recipeData }