This is a test header
+
This is a test 1
+
+
This is a test header 1
-
And this is a test content.
+
And this is a test content 1.
+
+
Next
+
+
+
Prev
+
diff --git a/examples/native/public/test2 b/examples/native/public/test2
new file mode 100644
index 0000000..1958ab5
--- /dev/null
+++ b/examples/native/public/test2
@@ -0,0 +1,22 @@
+
+
+
+
This is a test 2
+
+
+
+
+ This is a test 2
+
+ This is a test header 2
+
+
And this is a test content 2.
+
+
+
+ Prev
+
+
+
+
+
diff --git a/examples/native/public/test3 b/examples/native/public/test3
new file mode 100644
index 0000000..601f4bc
--- /dev/null
+++ b/examples/native/public/test3
@@ -0,0 +1,24 @@
+
+
+
+
This is a test 3
+
+
+
+
+ This is a test 3
+
+ This is a test header 3
+
+
And this is a test content 3.
+
+
+ Next
+
+
+ Prev
+
+
+
+
+
diff --git a/examples/native/public/test4 b/examples/native/public/test4
new file mode 100644
index 0000000..46be7f1
--- /dev/null
+++ b/examples/native/public/test4
@@ -0,0 +1,22 @@
+
+
+
+
This is a test 4
+
+
+
+
+ This is a test 4
+
+ This is a test header 4
+
+
And this is a test content 4.
+
+
+ Next
+
+
+
+
+
+
diff --git a/examples/native/templates/content.html b/examples/native/templates/content.html
index fb0858f..f9adcd8 100644
--- a/examples/native/templates/content.html
+++ b/examples/native/templates/content.html
@@ -3,5 +3,11 @@
{{ .Post.ShortPost.Title }}
{{ .Post.Content }}
+ {{ if .Next }}
+
Next
+ {{ end }}
+ {{ if .Prev }}
+
Prev
+ {{ end }}
{{ end }}
diff --git a/gen.go b/gen.go
index 0e156bd..474c84e 100644
--- a/gen.go
+++ b/gen.go
@@ -21,7 +21,6 @@ var (
postTplNm = "post.amber" // The amber post template file name (native Go are compiled using ParseGlob)
// Special files in the public directory, that must not be deleted
- // If value is true, this must match the prefix of the file (HasPrefix())
specFiles = map[string]struct{}{
"favicon.ico": struct{}{},
"robots.txt": struct{}{},
@@ -91,7 +90,7 @@ func compileTemplates() error {
// Clear the public directory, ignoring special files, subdirectories, and hidden (dot) files.
func clearPublicDir() error {
- // Clear the public directory, except subdirs and special files (favicon.ico)
+ // Clear the public directory, except subdirs and special files (favicon.ico & co.)
fis, err := ioutil.ReadDir(PublicDir)
if err != nil {
return fmt.Errorf("error getting public directory files: %s", err)
diff --git a/tpldata.go b/tpldata.go
index 7fd69b0..845296e 100644
--- a/tpldata.go
+++ b/tpldata.go
@@ -18,6 +18,14 @@ var (
ErrEmptyPost = fmt.Errorf("empty post file")
ErrInvalidFrontMatter = fmt.Errorf("invalid front matter")
ErrMissingFrontMatter = fmt.Errorf("missing front matter")
+
+ // Lookup table to find the format based on the length of the date in the front matter
+ pubDtFmt = map[int]string{
+ 10: "2006-01-02",
+ 14: "2006-01-02 15h",
+ 16: "2006-01-02 15:04",
+ 25: time.RFC3339,
+ }
)
// The TemplateData structure contains all the relevant information passed to the
@@ -123,8 +131,8 @@ func newLongPost(fi os.FileInfo) (*LongPost, error) {
slug := getSlug(fi.Name())
pubdt := fi.ModTime()
- if dt, ok := m["Date"]; ok {
- pubdt, err = time.Parse("2006-01-02", dt)
+ if dt, ok := m["Date"]; ok && len(dt) > 0 {
+ pubdt, err = time.Parse(pubDtFmt[len(dt)], dt)
if err != nil {
return nil, err
}