repos / pgit

static site generator for git
git clone https://github.com/picosh/pgit.git

commit
54f6fbc
parent
ad83ff1
author
Eric Bower
date
2024-01-16 14:36:40 +0000 UTC
fix(static): read from embed fs
1 files changed,  +5, -9
M main.go
+5, -9
 1@@ -24,10 +24,7 @@ import (
 2 	"go.uber.org/zap"
 3 )
 4 
 5-//go:embed static/*
 6-var sfs embed.FS
 7-
 8-//go:embed html/*.tmpl
 9+//go:embed html/*.tmpl static/*
10 var efs embed.FS
11 
12 type Config struct {
13@@ -332,9 +329,8 @@ func (c *Config) writeHtml(writeData *WriteData) {
14 	bail(err)
15 }
16 
17-func (c *Config) copyStatic() error {
18-	dir := "static"
19-	entries, err := sfs.ReadDir(dir)
20+func (c *Config) copyStatic(dir string) error {
21+	entries, err := efs.ReadDir(dir)
22 	bail(err)
23 
24 	for _, e := range entries {
25@@ -343,7 +339,7 @@ func (c *Config) copyStatic() error {
26 			continue
27 		}
28 
29-		w, err := os.ReadFile(infp)
30+		w, err := efs.ReadFile(infp)
31 		bail(err)
32 		fp := filepath.Join(c.Outdir, e.Name())
33 		c.Logger.Infof("writing (%s)", fp)
34@@ -1071,7 +1067,7 @@ func main() {
35 	}
36 
37 	config.writeRepo()
38-	config.copyStatic()
39+	config.copyStatic("static")
40 
41 	url := filepath.Join("/", "index.html")
42 	config.Logger.Info(url)