about summary refs log tree commit diff stats
path: root/internal/builder/builder.go
diff options
context:
space:
mode:
authorAlan Pearce2024-06-24 21:48:36 +0200
committerAlan Pearce2024-06-24 23:09:15 +0200
commita2feb8c63c80a1f52830f562af2deb2c6065eaae (patch)
tree448ed15c5fb91099ef29528c529a35d6151d98ee /internal/builder/builder.go
parent8623948592fa14958d340b006653fc57861c4fc4 (diff)
downloadwebsite-a2feb8c63c80a1f52830f562af2deb2c6065eaae.tar.lz
website-a2feb8c63c80a1f52830f562af2deb2c6065eaae.tar.zst
website-a2feb8c63c80a1f52830f562af2deb2c6065eaae.zip
move templ templates into separate package
Diffstat (limited to 'internal/builder/builder.go')
-rw-r--r--internal/builder/builder.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go
index 20714b9..933679d 100644
--- a/internal/builder/builder.go
+++ b/internal/builder/builder.go
@@ -14,6 +14,7 @@ import (
 	"website/internal/content"
 	"website/internal/log"
 	"website/internal/sitemap"
+	"website/templates"
 
 	"github.com/a-h/templ"
 	mapset "github.com/deckarep/golang-set/v2"
@@ -127,7 +128,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 		}
 		log.Debug("rendering post", "post", post.Basename)
 		sitemap.AddPath(post.URL, post.Date)
-		if err := renderToFile(postPage(config, post), post.Output); err != nil {
+		if err := renderToFile(templates.PostPage(config, post), post.Output); err != nil {
 			return nil, err
 		}
 	}
@@ -136,7 +137,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 		return nil, errors.WithMessage(err, "could not create directory for tags")
 	}
 	log.Debug("rendering tags list")
-	if err := renderToFile(tagsPage(config, "tags", mapset.Sorted(tags), "/tags"), publicDir, "tags", "index.html"); err != nil {
+	if err := renderToFile(templates.TagsPage(config, "tags", mapset.Sorted(tags), "/tags"), publicDir, "tags", "index.html"); err != nil {
 		return nil, err
 	}
 	sitemap.AddPath("/tags/", lastMod)
@@ -153,7 +154,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 		}
 		log.Debug("rendering tags page", "tag", tag)
 		url := "/tags/" + tag
-		if err := renderToFile(tagPage(config, tag, matchingPosts, url), publicDir, "tags", tag, "index.html"); err != nil {
+		if err := renderToFile(templates.TagPage(config, tag, matchingPosts, url), publicDir, "tags", tag, "index.html"); err != nil {
 			return nil, err
 		}
 		sitemap.AddPath(url, matchingPosts[0].Date)
@@ -174,7 +175,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 	}
 
 	log.Debug("rendering list page")
-	if err := renderToFile(listPage(config, posts, "/post"), publicDir, "post", "index.html"); err != nil {
+	if err := renderToFile(templates.ListPage(config, posts, "/post"), publicDir, "post", "index.html"); err != nil {
 		return nil, err
 	}
 	sitemap.AddPath("/post/", lastMod)
@@ -215,7 +216,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 	if err != nil {
 		return nil, err
 	}
-	if err := renderToFile(homepage(config, posts, content), publicDir, "index.html"); err != nil {
+	if err := renderToFile(templates.Homepage(config, posts, content), publicDir, "index.html"); err != nil {
 		return nil, err
 	}
 	// it would be nice to set LastMod here, but using the latest post
@@ -226,7 +227,7 @@ func build(outDir string, config config.Config) (*Result, error) {
 	r.Hashes = append(r.Hashes, h)
 
 	log.Debug("rendering 404 page")
-	if err := renderToFile(notFound(config, "/404.html"), privateDir, "404.html"); err != nil {
+	if err := renderToFile(templates.NotFound(config, "/404.html"), privateDir, "404.html"); err != nil {
 		return nil, err
 	}