From 08f90ec9f4d9a9af2f838b10e0865c37b848e8ca Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 30 Jul 2025 00:28:16 -0400 Subject: [PATCH] First running site gen working. --- config/loader.go | 1 + example/layouts/main/index.html | 0 example/pages/index.html | 3 +++ example/pages/layouts/main.html | 23 +++++++++++++++++++++++ example/ssgod.toml | 3 +++ main.go | 9 +++++++-- ssgod.toml | 2 -- 7 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 example/layouts/main/index.html create mode 100644 example/pages/index.html create mode 100644 example/pages/layouts/main.html create mode 100644 example/ssgod.toml delete mode 100644 ssgod.toml diff --git a/config/loader.go b/config/loader.go index 11dd381..cb4fb19 100644 --- a/config/loader.go +++ b/config/loader.go @@ -8,6 +8,7 @@ import ( type config struct { Views string `toml:"views"` Layouts string `toml:"layouts"` + Target string `toml:"target"` } var Settings config diff --git a/example/layouts/main/index.html b/example/layouts/main/index.html new file mode 100644 index 0000000..e69de29 diff --git a/example/pages/index.html b/example/pages/index.html new file mode 100644 index 0000000..d2c551f --- /dev/null +++ b/example/pages/index.html @@ -0,0 +1,3 @@ +

Your Content Here

+ +

Put your stuff here.

diff --git a/example/pages/layouts/main.html b/example/pages/layouts/main.html new file mode 100644 index 0000000..303cc05 --- /dev/null +++ b/example/pages/layouts/main.html @@ -0,0 +1,23 @@ + + + + + + + + + Super Saiyan God + +
+

Header Here

+
+ + + {{embed}} + + + + + diff --git a/example/ssgod.toml b/example/ssgod.toml new file mode 100644 index 0000000..1e9034a --- /dev/null +++ b/example/ssgod.toml @@ -0,0 +1,3 @@ +views = "./pages" +layouts = "layouts/main" +target = "./public" diff --git a/main.go b/main.go index 73a1dad..8a3d271 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,8 @@ func Fail(err error, format string, v ...any) error { return err } -func RenderPages(pages_path string, target string, layout string) { +func RenderPages(pages_path string, layout string, target string) { + log.Printf("LAYOUT IS: %v", layout) engine := html.New(pages_path, ".html") engine.Load() @@ -57,6 +58,7 @@ func RenderPages(pages_path string, target string, layout string) { // generate a data-testid for all pages based on template name page_id := strings.ReplaceAll(template_name, "/", "-") + "-page" + err = engine.Render(out, template_name, fiber.Map{"PageId": page_id}, layout) if err != nil { return Fail(err, "failed to render %s", path) } @@ -73,5 +75,8 @@ func RenderPages(pages_path string, target string, layout string) { func main() { config.Load("ssgod.toml") - log.Printf("views=%s, layouts=%s", config.Settings.Views, config.Settings.Layouts) + log.Printf("views=%s, layouts=%s, target=%s", + config.Settings.Views, config.Settings.Layouts, config.Settings.Target) + + RenderPages(config.Settings.Views, config.Settings.Layouts, config.Settings.Target) } diff --git a/ssgod.toml b/ssgod.toml deleted file mode 100644 index 8384591..0000000 --- a/ssgod.toml +++ /dev/null @@ -1,2 +0,0 @@ -views = "./views" -layouts = "layouts/main"