all repos — website @ 973fa31b6743a3ea84c86ab7671349cc70a69142

My website

enable filtered debug logging via DEBUG="component.*"

Alan Pearce
commit

973fa31b6743a3ea84c86ab7671349cc70a69142

parent

7b82d3ef3e93c0c8efe489d6b11b30f092667bf2

1 file changed, 11 insertions(+), 5 deletions(-)

changed files
M internal/content/posts.gointernal/content/posts.go
@@ -13,11 +13,11 @@ "go.alanpearce.eu/website/internal/log"
"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 @@
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" {