Optimized CSS Gen
This commit is contained in:
@ -15,7 +15,7 @@ tmp_dir = "tmp"
|
|||||||
follow_symlink = false
|
follow_symlink = false
|
||||||
full_bin = ""
|
full_bin = ""
|
||||||
include_dir = []
|
include_dir = []
|
||||||
include_ext = ["go", "tpl", "tmpl", "html"]
|
include_ext = ["go", "tpl", "tmpl", "html", "css"]
|
||||||
include_file = []
|
include_file = []
|
||||||
kill_delay = "0s"
|
kill_delay = "0s"
|
||||||
log = "build-errors.log"
|
log = "build-errors.log"
|
||||||
|
@ -5,3 +5,4 @@
|
|||||||
**/*.rdb
|
**/*.rdb
|
||||||
**/stylegen/**
|
**/stylegen/**
|
||||||
fly.toml
|
fly.toml
|
||||||
|
tailwind.config.*.js
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ goth.stack
|
|||||||
airbin
|
airbin
|
||||||
tmp/
|
tmp/
|
||||||
*.rdb
|
*.rdb
|
||||||
|
tailwind.config.*.js
|
5
main.go
5
main.go
@ -60,7 +60,10 @@ func main() {
|
|||||||
|
|
||||||
// Static server
|
// Static server
|
||||||
fs := http.FS(PublicFS)
|
fs := http.FS(PublicFS)
|
||||||
e.GET("/public/*", echo.WrapHandler(http.FileServer(fs)))
|
e.GET("/public/*", func(c echo.Context) error {
|
||||||
|
c.Response().Header().Set("Cache-Control", "public, max-age=3600")
|
||||||
|
return echo.WrapHandler(http.FileServer(fs))(c)
|
||||||
|
})
|
||||||
|
|
||||||
// Page routes
|
// Page routes
|
||||||
e.GET("/", pages.Home)
|
e.GET("/", pages.Home)
|
||||||
|
@ -7,6 +7,7 @@ GOTH // Blog
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
|
<link rel="stylesheet" href="/public/css/styles.blog.css" />
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
@ -7,6 +7,7 @@ GOTH // Home
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
|
<link rel="stylesheet" href="/public/css/styles.home.css" />
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<link rel="icon" href="/public/favicon.ico" />
|
<link rel="icon" href="/public/favicon.ico" />
|
||||||
<title>{{template "title" .}}</title>
|
<title>{{template "title" .}}</title>
|
||||||
<meta name="description" content="Just here for the vibes...">
|
<meta name="description" content="Just here for the vibes...">
|
||||||
<link rel="stylesheet" href="/public/css/styles.css" />
|
|
||||||
{{template "head" .}}
|
{{template "head" .}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<link rel="icon" href="/public/favicon.ico" />
|
<link rel="icon" href="/public/favicon.ico" />
|
||||||
<title>{{.Name}}</title>
|
<title>{{.Name}}</title>
|
||||||
<meta name="description" content="Just here for the vibes...">
|
<meta name="description" content="Just here for the vibes...">
|
||||||
<link rel="stylesheet" href="/public/css/styles.css" />
|
{{template "head" .}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="block h-[100%]">
|
<body class="block h-[100%]">
|
||||||
|
@ -7,6 +7,7 @@ GOTH // Post
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
|
<link rel="stylesheet" href="/public/css/styles.post.css" />
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
@ -5,6 +5,7 @@ GOTH // SSE <div class="badge badge-accent">DEMO</div>
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
|
<link rel="stylesheet" href="/public/css/styles.ssedemo.css" />
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
1
public/css/styles.blog.css
vendored
Normal file
1
public/css/styles.blog.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/css/styles.css
vendored
1
public/css/styles.css
vendored
File diff suppressed because one or more lines are too long
1
public/css/styles.home.css
vendored
Normal file
1
public/css/styles.home.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/css/styles.post.css
vendored
Normal file
1
public/css/styles.post.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/css/styles.ssedemo.css
vendored
Normal file
1
public/css/styles.ssedemo.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -49,5 +49,37 @@ fi
|
|||||||
|
|
||||||
echo $BINARY
|
echo $BINARY
|
||||||
|
|
||||||
# Run the binary
|
# Infer pages from .html files in the pages directory
|
||||||
$BINARY build -i ./base.css -o ../public/css/styles.css --minify
|
PAGES=$(ls ../pages/templates/*.html | xargs -n 1 basename | cut -d. -f1)
|
||||||
|
|
||||||
|
# Run the binary for each page
|
||||||
|
for PAGE in $PAGES; do
|
||||||
|
(
|
||||||
|
# Detect which partials are being used in this page
|
||||||
|
PARTIALS=$(grep -o -E '{{template "[^"]+' ../pages/templates/${PAGE}.html | cut -d'"' -f2 | xargs -I{} echo \"../pages/templates/partials/{}.html\")
|
||||||
|
|
||||||
|
# Generate an array of partials and join them with commas
|
||||||
|
PARTIALS_ARRAY=$(echo $PARTIALS | tr ' ' ',')
|
||||||
|
|
||||||
|
# Always include the "header" partial and any other partials that are always used
|
||||||
|
PARTIALS_ARRAY=\"../pages/templates/partials/header.html\",\"../pages/templates/partials/global.html\",$PARTIALS_ARRAY
|
||||||
|
|
||||||
|
# Generate Tailwind config for this page
|
||||||
|
echo "module.exports = {
|
||||||
|
content: [\"../pages/templates/${PAGE}.html\", \"../pages/templates/layouts/*.html\", $PARTIALS_ARRAY],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
daisyui: {
|
||||||
|
themes: [\"night\"],
|
||||||
|
},
|
||||||
|
plugins: [require('daisyui'), require('@tailwindcss/typography')],
|
||||||
|
}" > tailwind.config.${PAGE}.js
|
||||||
|
|
||||||
|
# Run the binary with the generated config
|
||||||
|
$BINARY build -i ./base.css -c tailwind.config.${PAGE}.js -o ../public/css/styles.${PAGE}.css --minify
|
||||||
|
) &
|
||||||
|
done
|
||||||
|
|
||||||
|
# Wait for all background processes to finish
|
||||||
|
wait
|
12
stylegen/tailwind.config.js
vendored
12
stylegen/tailwind.config.js
vendored
@ -1,12 +0,0 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
|
||||||
module.exports = {
|
|
||||||
content: ["../pages/**/*.{html,go}"],
|
|
||||||
theme: {
|
|
||||||
extend: {},
|
|
||||||
},
|
|
||||||
daisyui: {
|
|
||||||
themes: ["night"],
|
|
||||||
},
|
|
||||||
plugins: [require('daisyui'), require('@tailwindcss/typography')],
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user