aboutsummaryrefslogtreecommitdiff
path: root/xess/xess.go
blob: d4058718267b9ffe586757dbcbba7acc47ca0136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package xess vendors a copy of Xess and makes it available at /.xess/xess.css
//
// This is intended to be used as a vendored package in other projects.
package xess

import (
	"embed"
	"net/http"

	"within.website/x"
	"within.website/x/internal"
)

//go:generate go run github.com/a-h/templ/cmd/templ@latest generate
//go:generate npm ci
//go:generate npm run build

var (
	//go:embed xess.min.css static
	Static embed.FS

	URL = "/.within.website/x/xess/xess.min.css"
)

func init() {
	Mount(http.DefaultServeMux)
	URL = URL + "?cachebuster=" + x.Version
}

func Mount(mux *http.ServeMux) {
	mux.Handle("/.within.website/x/xess/", internal.UnchangingCache(http.StripPrefix("/.within.website/x/xess/", http.FileServerFS(Static))))
}