about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-04-17 20:24:29 +0200
committerAlan Pearce2024-04-17 20:53:45 +0200
commit3197e0e759814741d2729461b41860c5d1e54701 (patch)
treee45a2d5aa7d89428fdd02fc8f81cf379e7e8bc7c
parent597c7944e65a95fd8fb39570df354f3beda16127 (diff)
downloadwebsite-3197e0e759814741d2729461b41860c5d1e54701.tar.lz
website-3197e0e759814741d2729461b41860c5d1e54701.tar.zst
website-3197e0e759814741d2729461b41860c5d1e54701.zip
remove purgeCSS for now
-rw-r--r--cmd/build/build.go36
1 files changed, 2 insertions, 34 deletions
diff --git a/cmd/build/build.go b/cmd/build/build.go
index a8ce710..ddc7a6b 100644
--- a/cmd/build/build.go
+++ b/cmd/build/build.go
@@ -2,7 +2,6 @@ package main
 
 import (
 	"bytes"
-	"encoding/json"
 	"encoding/xml"
 	"fmt"
 	"io"
@@ -11,7 +10,6 @@ import (
 	"log/slog"
 	"net/url"
 	"os"
-	"os/exec"
 	"path"
 	"path/filepath"
 	"slices"
@@ -125,45 +123,15 @@ func readPosts(root string, inputDir string, outputDir string) ([]Post, Tags, er
 	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 {