all repos — homestead @ a496d10c937000c518789aa2932976136ed2bb0f

Code for my website

remove purgeCSS for now

Alan Pearce
commit

a496d10c937000c518789aa2932976136ed2bb0f

parent

d1ba9235990cd80589ec930a7c441d8510234564

1 file changed, 2 insertions(+), 34 deletions(-)

jump to
M cmd/build/build.gocmd/build/build.go
@@ -2,7 +2,6 @@ package main
import ( "bytes" - "encoding/json" "encoding/xml" "fmt" "io"
@@ -11,7 +10,6 @@ "log"
"log/slog" "net/url" "os" - "os/exec" "path" "path/filepath" "slices"
@@ -125,45 +123,15 @@ })
return posts, tags, nil } -type purgeCSSOutput struct { - CSS string `json:"css"` - File string -} - -var purgedCSS map[string]string - -func purgeCSS(htmlFilename string, cssFilename string) (string, error) { - if purgedCSS == nil { - purgedCSS = make(map[string]string) - } else if purgedCSS[htmlFilename] == "" { - slog.Debug("running purgecss", "html", htmlFilename, "css", cssFilename) - bytes, err := exec.Command("bun", "./node_modules/.bin/purgecss", "--css", cssFilename, "--content", htmlFilename).Output() - if err != nil { - return "", errors.WithMessage(err, "failed running `purgecss` command") - } - var out []purgeCSSOutput - err = json.Unmarshal(bytes, &out) - if err != nil { - return "", errors.WithMessage(err, "failed decoding `purgecss` output") - } - purgedCSS[htmlFilename] = out[0].CSS - } - return purgedCSS[htmlFilename], nil -} - func layout(filename string, config Config, pageTitle string) (*goquery.Document, error) { html, err := os.Open(filename) if err != nil { return nil, err } defer html.Close() - css, err := purgeCSS(filename, "templates/style.css") + css, err := os.ReadFile("templates/style.css") if err != nil { - bytes, err := os.ReadFile("templates/style.css") - if err != nil { - return nil, err - } - css = string(bytes) + return nil, err } doc, err := goquery.NewDocumentFromReader(html) if err != nil {