From 6c4a3268bc4c528ecff45f50ed5ca6aa1d48500c Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 28 Jun 2024 20:43:14 +0200 Subject: wip --- internal/builder/builder.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'internal/builder') 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 } -- cgit 1.4.1