From 2fb30f2f4c044f101d5b7b03eb50a05d716d98f1 Mon Sep 17 00:00:00 2001 From: unwox Date: Tue, 22 Oct 2024 22:12:38 +0600 Subject: inline style.css into html --- bin/serve.fnl | 4 +++- lib/fs.fnl | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 lib/fs.fnl diff --git a/bin/serve.fnl b/bin/serve.fnl index 51f5d6b..d96056a 100644 --- a/bin/serve.fnl +++ b/bin/serve.fnl @@ -10,6 +10,7 @@ (local array (require :lib.array)) (local str (require :lib.string)) (local texts (require :texts)) +(local fs (require :lib.fs)) (local spellfix (require :lib.spellfix)) (local cache (require :lib.cache)) (local {: must : measure} (require :lib.utils)) @@ -355,7 +356,8 @@ [:head {} [:meta {:charset "utf-8"}] [:meta {:name "viewport" :content "width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=5.0"}] - [:link {:rel "stylesheet" :href "/static/style.css"}] + ;; inline styles so the page loads faster + [:style {} [:NO-ESCAPE (fs.read-file "static/style.css")]] [:link {:rel "icon" :href "/static/favicon.png"}] [:link {:rel "preload" :href "/static/logo-hor.svg"}] [:title {} (if (str.empty? form.query) diff --git a/lib/fs.fnl b/lib/fs.fnl new file mode 100644 index 0000000..e56eb8f --- /dev/null +++ b/lib/fs.fnl @@ -0,0 +1,5 @@ +(fn read-file [file] + (with-open [f (io.open file "r")] + (f:read :*all))) + +{: read-file} -- cgit v1.2.3