Split CSS into multiple files

This shouldn't result in anything breaking,
will require thorough testing
This commit is contained in:
Svilen Markov
2025-03-20 16:57:55 +00:00
parent 568876fc4f
commit 43b8f8f31b
28 changed files with 2222 additions and 2121 deletions
+17 -1
View File
@@ -20,6 +20,8 @@ var (
pageThemeStyleTemplate = mustParseTemplate("theme-style.gotmpl")
)
const STATIC_ASSETS_CACHE_DURATION = 24 * time.Hour
type application struct {
Version string
Config config
@@ -230,9 +232,23 @@ func (a *application) server() (func() error, func() error) {
mux.Handle(
fmt.Sprintf("GET /static/%s/{path...}", staticFSHash),
http.StripPrefix("/static/"+staticFSHash, fileServerWithCache(http.FS(staticFS), 24*time.Hour)),
http.StripPrefix(
"/static/"+staticFSHash,
fileServerWithCache(http.FS(staticFS), STATIC_ASSETS_CACHE_DURATION),
),
)
cssBundleCacheControlValue := fmt.Sprintf(
"public, max-age=%d",
int(STATIC_ASSETS_CACHE_DURATION.Seconds()),
)
mux.HandleFunc(fmt.Sprintf("GET /static/%s/css/bundle.css", staticFSHash), func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", cssBundleCacheControlValue)
w.Header().Add("Content-Type", "text/css; charset=utf-8")
w.Write(bundledCSSContents)
})
var absAssetsPath string
if a.Config.Server.AssetsPath != "" {
absAssetsPath, _ = filepath.Abs(a.Config.Server.AssetsPath)