Optize font performance

This commit is contained in:
2026-04-18 07:56:14 +02:00
parent c85ea3bb0c
commit eee79b34bb
3 changed files with 11 additions and 1 deletions
+2
View File
@@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{.Title}}</title>
<link rel="icon" href="/_/favicon.ico" />
<link rel="preload" href="/_/fonts/IosevkaEtoile.woff2" as="font" type="font/woff2" crossorigin />
<link rel="preload" href="/_/fonts/IosevkaSlab.woff2" as="font" type="font/woff2" crossorigin />
<link rel="stylesheet" href="/_/style.css" />
<script src="/_/global-shortcuts.js"></script>
</head>
+2
View File
@@ -2,10 +2,12 @@
@font-face {
font-family: "Iosevka Etoile";
src: url("/_/fonts/IosevkaEtoile.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: "Iosevka Slab";
src: url("/_/fonts/IosevkaSlab.woff2") format("woff2");
font-display: swap;
}
/* === Theme === */
+7 -1
View File
@@ -54,7 +54,13 @@ func main() {
h := &handler{root: root, user: *user, pass: *pass}
staticFS, _ := fs.Sub(assets, "assets")
http.Handle("/_/", http.StripPrefix("/_/", http.FileServer(http.FS(staticFS))))
static := http.StripPrefix("/_/", http.FileServer(http.FS(staticFS)))
http.Handle("/_/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/_/fonts/") {
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
}
static.ServeHTTP(w, r)
}))
http.Handle("/", h)
log.Printf("datascape listening on %s, wiki at %s", *addr, root)