Repos / s4g / bcc2b10444
commit bcc2b104449d667b121ef3651aa90b8d8b8c30c5
Author: Nhân <hi@imnhan.com>
Date:   Wed Aug 23 22:02:14 2023 +0700

    allow custom footer msg

diff --git a/docs/_s4g/theme/includes.tmpl b/docs/_s4g/theme/includes.tmpl
index 652d4a1..018b4d4 100644
--- a/docs/_s4g/theme/includes.tmpl
+++ b/docs/_s4g/theme/includes.tmpl
@@ -23,7 +23,7 @@
 {{- if .Site.ShowFooter -}}
 <footer>
 © {{if eq .StartYear .Now.Year}}{{.StartYear}}{{else}}{{.StartYear}}–{{.Now.Year}}{{end}} {{.Site.AuthorName}}<br>
-Made with <a href="https://github.com/nhanb/s4g">s4g</a>
+{{.Site.FooterText}}
 </footer>
 {{- end -}}
 {{- end}}
diff --git a/metadata.go b/metadata.go
index 98981dc..fb90aee 100644
--- a/metadata.go
+++ b/metadata.go
@@ -4,6 +4,7 @@
 	"bufio"
 	"bytes"
 	"fmt"
+	"html/template"
 	"io"
 	"io/fs"
 	"reflect"
@@ -21,6 +22,7 @@ type SiteMetadata struct {
 	Tagline       string
 	Root          string
 	ShowFooter    bool
+	FooterText    template.HTML
 	NavbarLinks   []string
 	DefaultThumb  string
 	AuthorName    string
@@ -83,6 +85,7 @@ func NewSiteMetadata() SiteMetadata {
 	return SiteMetadata{
 		Root:        "/",
 		ShowFooter:  true,
+		FooterText:  `Made with <a href="https://github.com/nhanb/s4g">s4g</a>`,
 		NavbarLinks: []string{"index.dj"},
 	}
 }
@@ -199,6 +202,10 @@ func UnmarshalMetadata(data []byte, dest any) *errs.UserErr {
 				}
 				s.Field(i).Set(reflect.ValueOf(pt))
 
+			case "template.HTML":
+				html := template.HTML(val)
+				s.Field(i).Set(reflect.ValueOf(html))
+
 			default:
 				panic(fmt.Sprintf(
 					`unsupported metadata field type: "%s"`,
diff --git a/theme/includes.tmpl b/theme/includes.tmpl
index 652d4a1..018b4d4 100644
--- a/theme/includes.tmpl
+++ b/theme/includes.tmpl
@@ -23,7 +23,7 @@
 {{- if .Site.ShowFooter -}}
 <footer>
 © {{if eq .StartYear .Now.Year}}{{.StartYear}}{{else}}{{.StartYear}}–{{.Now.Year}}{{end}} {{.Site.AuthorName}}<br>
-Made with <a href="https://github.com/nhanb/s4g">s4g</a>
+{{.Site.FooterText}}
 </footer>
 {{- end -}}
 {{- end}}