From 67a77c2cf1e15ad913547d3c1c05e7bd84f3ba95 Mon Sep 17 00:00:00 2001 From: kpym Date: Fri, 17 Jan 2025 18:56:07 +0100 Subject: [PATCH] append icon paramter for the favicon --- gm_compile.go | 5 +++++ gm_parameters.go | 2 ++ gm_template.html | 3 +++ 3 files changed, 10 insertions(+) diff --git a/gm_compile.go b/gm_compile.go index 1b4f9f5..8f5a0b0 100644 --- a/gm_compile.go +++ b/gm_compile.go @@ -42,11 +42,16 @@ func compile(markdown []byte) (html []byte, err error) { // combine the template and the resulting html var data = make(map[string]any) + // the title as parameter or from the first h1 if title != "" { data["title"] = template.HTML(title) } else { data["title"] = template.HTML(getTitle(htmlStr)) } + // the favicon url + if favicon != "" { + data["favicon"] = template.HTML(favicon) + } // the css can be either an url or a code type cssType struct { Url template.HTML diff --git a/gm_parameters.go b/gm_parameters.go index 929a9f0..40e5725 100644 --- a/gm_parameters.go +++ b/gm_parameters.go @@ -63,6 +63,7 @@ var ( // template flags css []string title string + favicon string htmlshell string liveupdate bool @@ -112,6 +113,7 @@ func SetParameters() { pflag.StringArrayVarP(&css, "css", "c", []string{"github"}, "A css content or url or the theme name present in github.com/kpym/markdown-css. Multiple values are allowed.") pflag.StringVarP(&title, "title", "t", "", "The page title. If empty, search for

in the resulting html.") + pflag.StringVar(&favicon, "icon", "", "The favicon url.") pflag.StringVar(&htmlshell, "html", "", "The html template (file or string).") pflag.StringVarP(&outdir, "out-dir", "o", "", "The build output folder (created if not already existing, not used when serving).") diff --git a/gm_template.html b/gm_template.html index 53ce754..7b49c60 100644 --- a/gm_template.html +++ b/gm_template.html @@ -12,6 +12,9 @@ {{.}} {{- end }} {{- end }} + {{- with .favicon }} + + {{- end }} {{- with .title }} {{.}} {{- end }}