about summary refs log tree commit diff stats
path: root/internal/builder
diff options
context:
space:
mode:
authorAlan Pearce2024-06-28 20:43:14 +0200
committerAlan Pearce2024-06-29 16:50:51 +0200
commit6c4a3268bc4c528ecff45f50ed5ca6aa1d48500c (patch)
tree6663946e586d5c0745b984a0a809fc2330ce70d0 /internal/builder
parentb4095d108a2646bcf9e7fff64788b10d9bce8da3 (diff)
downloadwebsite-postdate.tar.lz
website-postdate.tar.zst
website-postdate.zip
Diffstat (limited to 'internal/builder')
-rw-r--r--internal/builder/builder.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go
index a4e44c6..928e4df 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/internal/vcs"
 	"website/templates"
 
 	"github.com/a-h/templ"
@@ -22,15 +23,18 @@ import (
 )
 
 type IOConfig struct {
-	Source      string `conf:"default:.,short:s,flag:src"`
-	Destination string `conf:"default:public,short:d,flag:dest"`
-	Development bool   `conf:"default:false,flag:dev"`
+	Source      string          `conf:"default:.,short:s,flag:src"`
+	Destination string          `conf:"default:public,short:d,flag:dest"`
+	Development bool            `conf:"default:false,flag:dev"`
+	Repository  *vcs.Repository `conf:"-"`
 }
 
 type Result struct {
 	Hashes []string
 }
 
+const ContentRoot = "content"
+
 var compressFiles = false
 
 func mkdirp(dirs ...string) error {
@@ -110,7 +114,11 @@ func build(ioConfig *IOConfig, config *config.Config) (*Result, error) {
 		return nil, errors.WithMessage(err, "could not create post output directory")
 	}
 	log.Debug("reading posts")
-	posts, tags, err := content.ReadPosts(joinSource("content"), "post", outDir)
+	posts, tags, err := content.ReadPosts(&content.Config{
+		Root:      joinSource(ContentRoot),
+		InputDir:  "post",
+		OutputDir: outDir,
+	})
 	if err != nil {
 		return nil, err
 	}
@@ -219,7 +227,7 @@ func build(ioConfig *IOConfig, config *config.Config) (*Result, error) {
 	r.Hashes = append(r.Hashes, h)
 
 	log.Debug("rendering homepage")
-	_, text, err := content.GetPost(joinSource(filepath.Join("content", "index.md")))
+	_, text, err := content.GetPost(joinSource(filepath.Join(ContentRoot, "index.md")))
 	if err != nil {
 		return nil, err
 	}