about summary refs log tree commit diff stats
path: root/internal/content
diff options
context:
space:
mode:
Diffstat (limited to 'internal/content')
-rw-r--r--internal/content/posts.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/internal/content/posts.go b/internal/content/posts.go
index 000cd98..dd14d1e 100644
--- a/internal/content/posts.go
+++ b/internal/content/posts.go
@@ -13,11 +13,11 @@ import (
 
 	"github.com/adrg/frontmatter"
 	mapset "github.com/deckarep/golang-set/v2"
-	"gitlab.com/tozd/go/errors"
 	fences "github.com/stefanfritsch/goldmark-fences"
 	"github.com/yuin/goldmark"
 	"github.com/yuin/goldmark/extension"
 	htmlrenderer "github.com/yuin/goldmark/renderer/html"
+	"gitlab.com/tozd/go/errors"
 )
 
 type PostMatter struct {
@@ -80,16 +80,22 @@ func RenderMarkdown(content []byte) (string, error) {
 	return buf.String(), nil
 }
 
-func ReadPosts(root string, inputDir string, outputDir string) ([]Post, Tags, error) {
+type Config struct {
+	Root      string
+	InputDir  string
+	OutputDir string
+}
+
+func ReadPosts(config *Config, log *log.Logger) ([]Post, Tags, error) {
 	tags := mapset.NewSet[string]()
 	posts := []Post{}
-	subdir := filepath.Join(root, inputDir)
+	subdir := filepath.Join(config.Root, config.InputDir)
 	files, err := os.ReadDir(subdir)
 	if err != nil {
 		return nil, nil, errors.WithMessagef(err, "could not read post directory %s", subdir)
 	}
-	outputReplacer := strings.NewReplacer(root, outputDir, ".md", "/index.html")
-	urlReplacer := strings.NewReplacer(root, "", ".md", "/")
+	outputReplacer := strings.NewReplacer(config.Root, config.OutputDir, ".md", "/index.html")
+	urlReplacer := strings.NewReplacer(config.Root, "", ".md", "/")
 	for _, f := range files {
 		pathFromRoot := filepath.Join(subdir, f.Name())
 		if !f.IsDir() && path.Ext(pathFromRoot) == ".md" {