Skip to content

Commit

Permalink
append icon paramter for the favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Jan 17, 2025
1 parent 6613b37 commit 67a77c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gm_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gm_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var (
// template flags
css []string
title string
favicon string
htmlshell string
liveupdate bool

Expand Down Expand Up @@ -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 <h1> 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).")
Expand Down
3 changes: 3 additions & 0 deletions gm_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
{{.}}
{{- end }}
{{- end }}
{{- with .favicon }}
<link rel="icon" href="{{.}}">
{{- end }}
{{- with .title }}
<title>{{.}}</title>
{{- end }}
Expand Down

0 comments on commit 67a77c2

Please sign in to comment.