Skip to content

Commit 67a77c2

Browse files
committed
append icon paramter for the favicon
1 parent 6613b37 commit 67a77c2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

gm_compile.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ func compile(markdown []byte) (html []byte, err error) {
4242

4343
// combine the template and the resulting html
4444
var data = make(map[string]any)
45+
// the title as parameter or from the first h1
4546
if title != "" {
4647
data["title"] = template.HTML(title)
4748
} else {
4849
data["title"] = template.HTML(getTitle(htmlStr))
4950
}
51+
// the favicon url
52+
if favicon != "" {
53+
data["favicon"] = template.HTML(favicon)
54+
}
5055
// the css can be either an url or a code
5156
type cssType struct {
5257
Url template.HTML

gm_parameters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var (
6363
// template flags
6464
css []string
6565
title string
66+
favicon string
6667
htmlshell string
6768
liveupdate bool
6869

@@ -112,6 +113,7 @@ func SetParameters() {
112113

113114
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.")
114115
pflag.StringVarP(&title, "title", "t", "", "The page title. If empty, search for <h1> in the resulting html.")
116+
pflag.StringVar(&favicon, "icon", "", "The favicon url.")
115117
pflag.StringVar(&htmlshell, "html", "", "The html template (file or string).")
116118

117119
pflag.StringVarP(&outdir, "out-dir", "o", "", "The build output folder (created if not already existing, not used when serving).")

gm_template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
{{.}}
1313
{{- end }}
1414
{{- end }}
15+
{{- with .favicon }}
16+
<link rel="icon" href="{{.}}">
17+
{{- end }}
1518
{{- with .title }}
1619
<title>{{.}}</title>
1720
{{- end }}

0 commit comments

Comments
 (0)