Optize font performance
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
<link rel="icon" href="/_/favicon.ico" />
|
<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" />
|
<link rel="stylesheet" href="/_/style.css" />
|
||||||
<script src="/_/global-shortcuts.js"></script>
|
<script src="/_/global-shortcuts.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Iosevka Etoile";
|
font-family: "Iosevka Etoile";
|
||||||
src: url("/_/fonts/IosevkaEtoile.woff2") format("woff2");
|
src: url("/_/fonts/IosevkaEtoile.woff2") format("woff2");
|
||||||
|
font-display: swap;
|
||||||
}
|
}
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Iosevka Slab";
|
font-family: "Iosevka Slab";
|
||||||
src: url("/_/fonts/IosevkaSlab.woff2") format("woff2");
|
src: url("/_/fonts/IosevkaSlab.woff2") format("woff2");
|
||||||
|
font-display: swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* === Theme === */
|
/* === Theme === */
|
||||||
|
|||||||
@@ -54,7 +54,13 @@ func main() {
|
|||||||
h := &handler{root: root, user: *user, pass: *pass}
|
h := &handler{root: root, user: *user, pass: *pass}
|
||||||
|
|
||||||
staticFS, _ := fs.Sub(assets, "assets")
|
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)
|
http.Handle("/", h)
|
||||||
|
|
||||||
log.Printf("datascape listening on %s, wiki at %s", *addr, root)
|
log.Printf("datascape listening on %s, wiki at %s", *addr, root)
|
||||||
|
|||||||
Reference in New Issue
Block a user