aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-05-09 02:09:34 +0700
committerShulhan <ms@kilabit.info>2019-05-09 02:09:34 +0700
commitad42ce37ff411fccbcfe5d441e2babb8eb2244ed (patch)
tree555c273002c55e72c7169fc302e25501bd4fc53a
parent542b5a492f17e6f8e2d2d17dcd06ee26ae257ea6 (diff)
downloadciigo-ad42ce37ff411fccbcfe5d441e2babb8eb2244ed.tar.xz
filehtml: save other metadata as map of string to string
One can use the map in template using the following syntax {{ index .Metadata "key" }}
-rw-r--r--filehtml.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/filehtml.go b/filehtml.go
index 766fbed..a31b28a 100644
--- a/filehtml.go
+++ b/filehtml.go
@@ -13,9 +13,10 @@ import (
// fileHTML represent an HTML metadata for header and its body.
//
type fileHTML struct {
- Title string
- Styles []string
- Body template.HTML
+ Title string
+ Styles []string
+ Body template.HTML
+ Metadata map[string]string
path string
rawBody strings.Builder
@@ -38,12 +39,16 @@ func (fhtml *fileHTML) reset() {
// rawBody to template.HTML.
//
func (fhtml *fileHTML) unpackAdoc(fa *fileAdoc) {
+ fhtml.Metadata = make(map[string]string)
+
for k, v := range fa.metadata {
switch k {
case "doctitle":
fhtml.Title = v.(string)
case "stylesheet":
fhtml.Styles = append(fhtml.Styles, v.(string))
+ default:
+ fhtml.Metadata[k] = v.(string)
}
}