Optize font performance
This commit is contained in:
@@ -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,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 === */
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user