aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filehtml.go14
-rw-r--r--template_index_html.go7
2 files changed, 18 insertions, 3 deletions
diff --git a/filehtml.go b/filehtml.go
index c3f06e6..dc4384d 100644
--- a/filehtml.go
+++ b/filehtml.go
@@ -8,7 +8,9 @@ import (
"fmt"
"html/template"
"strings"
+ "time"
+ "github.com/bytesparadise/libasciidoc/pkg/configuration"
"github.com/bytesparadise/libasciidoc/pkg/types"
)
@@ -90,4 +92,16 @@ func (fhtml *fileHTML) unpackAdocMetadata(doc types.Document, md types.Metadata)
fhtml.Metadata[k] = fmt.Sprintf("%v", v)
}
}
+
+ if len(fhtml.Date) == 0 {
+ return
+ }
+
+ dt, err := time.Parse(configuration.LastUpdatedFormat, fhtml.Date)
+ if err == nil {
+ if dt.IsZero() {
+ fhtml.Date = ""
+ }
+ return
+ }
}
diff --git a/template_index_html.go b/template_index_html.go
index cc9c54b..52a775e 100644
--- a/template_index_html.go
+++ b/template_index_html.go
@@ -39,9 +39,10 @@ const templateIndexHTML = `<!DOCTYPE html>
<div class="container">
<h1>{{.Title}}</h1>
<div class="meta">
- {{.Author}}
- <br />
- {{.Date}}
+ {{if .Author}}{{.Author}}{{end}}
+ {{- if .Date}}<br />
+ {{.Date}}
+ {{- end}}
</div>
{{.Body}}
</div>