|
|
|
|
@ -2,6 +2,7 @@ package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"bytes" |
|
|
|
|
_ "embed" |
|
|
|
|
"flag" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/fsnotify/fsnotify" |
|
|
|
|
@ -15,7 +16,6 @@ import ( |
|
|
|
|
"strings" |
|
|
|
|
"text/template" |
|
|
|
|
"time" |
|
|
|
|
_ "embed" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
//go:embed example/.ssgod.json
|
|
|
|
|
@ -56,7 +56,9 @@ func RenderTemplate(out io.Writer, embed string, variables any) error { |
|
|
|
|
callbacks := template.FuncMap{ |
|
|
|
|
"embed": func() string { |
|
|
|
|
tmpl, err = tmpl.Parse(embed) |
|
|
|
|
if err != nil { Fatal(err, "error in your template") } |
|
|
|
|
if err != nil { |
|
|
|
|
Fatal(err, "error in your template") |
|
|
|
|
} |
|
|
|
|
out := bytes.NewBuffer(make([]byte, 0, 100)) |
|
|
|
|
tmpl.Execute(out, variables) |
|
|
|
|
return out.String() |
|
|
|
|
@ -264,10 +266,14 @@ func RenderPages() { |
|
|
|
|
|
|
|
|
|
err := filepath.WalkDir(config.Settings.Views, |
|
|
|
|
func(path string, d fs.DirEntry, err error) error { |
|
|
|
|
if err != nil { return err } |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err = ProcessDirEntry(path, d, meta) |
|
|
|
|
if err != nil { return Fail(err, "failed to process %s", path) } |
|
|
|
|
if err != nil { |
|
|
|
|
return Fail(err, "failed to process %s", path) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return err |
|
|
|
|
}) |
|
|
|
|
|