From 96dc9ce119def4e21ae14ba689b45f24dfb68099 Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Tue, 22 Oct 2024 16:57:52 -0300 Subject: [PATCH] feat(perf,layouts,css): place global css in style tag for instant loading --- templates/layouts/page.templ | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/templates/layouts/page.templ b/templates/layouts/page.templ index 3e4df4f..237a2cc 100644 --- a/templates/layouts/page.templ +++ b/templates/layouts/page.templ @@ -1,7 +1,11 @@ package layouts import ( + "fmt" + "embed" + "forge.capytal.company/capytalcode/project-comicverse/configs" + "forge.capytal.company/capytalcode/project-comicverse/assets" ) type PageInfo struct { @@ -20,6 +24,18 @@ func pageInfo(info []PageInfo) PageInfo { return PageInfo{} } +templ LinkCSSFile(href string, fs embed.FS, file string) { + if configs.DEVELOPMENT { + + + } else if f, err := fs.ReadFile(file); err != nil { + + + } else { + @templ.Raw(fmt.Sprintf("", f)) + } +} + templ Page(i ...PageInfo) { @@ -47,14 +63,12 @@ templ Page(i ...PageInfo) { } // Global styles - - - - + @LinkCSSFile("/assets/css/theme.css", assets.ASSETS, "css/theme.css") + @LinkCSSFile("/assets/css/uno.css", assets.ASSETS, "css/uno.css") // Global scripts // Additional heading