@@ -7,9 +7,7 @@ import (
77 "errors"
88 "fmt"
99 "html/template"
10- "io/fs"
1110 "os"
12- "os/exec"
1311 "path/filepath"
1412 "slices"
1513 "strconv"
@@ -34,6 +32,7 @@ var funcs = template.FuncMap{
3432 }
3533 return s
3634 },
35+ "asset": asset,
3736 "inc": func(i int) int { return i + 1 },
3837 "maxDiff": func() int { return MaxDiffLines },
3938 "dec": func(i int) int { return i - 1 },
@@ -56,7 +55,10 @@ var pages = template.Must(template.New("").Funcs(funcs).ParseFS(templates, "temp
5655 func Build(projects []project.Project, out, tailwind string) error {
5756 shown := slices.DeleteFunc(slices.Clone(projects), func(p project.Project) bool { return p.Hidden != "" })
5857 rows := Rows(shown)
59- stamp, fresh, err := readStamp(out)
58+ if err := writeAssets(out, tailwind); err != nil {
59+ return err
60+ }
61+ stamp, fresh, err := readStamp(out, fmt.Sprint(versions))
6062 if err != nil {
6163 return err
6264 }
@@ -96,17 +98,12 @@ func Build(projects []project.Project, out, tailwind string) error {
9698 return err
9799 }
98100 }
99- if err := copyStatic(out); err != nil || tailwind == "" {
100- return err
101- }
102- cmd := exec.Command(tailwind, "-i", "internal/site/assets/site.css", "-o", filepath.Join(out, "site.css"), "--minify")
103- cmd.Stderr = os.Stderr
104- return cmd.Run()
101+ return nil
105102 }
106103
107-// readStamp hashes this program, which holds every template, and says whether out was built by it.
108-// Pages that never change, such as commits, are only rendered again by a different program.
109-func readStamp(out string) (stamp string, fresh bool, err error) {
104+// readStamp hashes this program, which holds every template, with the asset versions, and says whether out was built by them.
105+// Pages that never change, such as commits, are only rendered again by a different program or new assets.
106+func readStamp(out, assets string) (stamp string, fresh bool, err error) {
110107 exe, err := os.Executable()
111108 if err != nil {
112109 return "", false, err
@@ -115,7 +112,7 @@ func readStamp(out string) (stamp string, fresh bool, err error) {
115112 if err != nil {
116113 return "", false, err
117114 }
118- stamp = fmt.Sprintf("%x", sha256.Sum256(b))
115+ stamp = fmt.Sprintf("%x %s", sha256.Sum256(b), assets)
119116 old, _ := os.ReadFile(filepath.Join(out, ".stamp"))
120117 return stamp, string(old) == stamp, nil
121118 }
@@ -131,16 +128,3 @@ func render(path, name string, data any) error {
131128 defer f.Close()
132129 return pages.ExecuteTemplate(f, name, data)
133130 }
134-
135-func copyStatic(out string) error {
136- return fs.WalkDir(static, "static", func(path string, d fs.DirEntry, err error) error {
137- if err != nil || d.IsDir() {
138- return err
139- }
140- b, err := static.ReadFile(path)
141- if err != nil {
142- return err
143- }
144- return os.WriteFile(filepath.Join(out, strings.TrimPrefix(path, "static/")), b, 0o644)
145- })
146-}