From 95ceed33d3adec472f4a1b5d3517baf645766e44 Mon Sep 17 00:00:00 2001 From: delta Date: Sat, 25 Jul 2026 11:42:01 +0200 Subject: site rework!! --- .zs/styles | 58 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to '.zs/styles') diff --git a/.zs/styles b/.zs/styles index c51a369..bbe31ba 100755 --- a/.zs/styles +++ b/.zs/styles @@ -1,14 +1,52 @@ -#!/bin/sh +#!/usr/bin/lua -set -e +---@class Stylesheet +---@field name string +---@field lazy? boolean -CSS="reset main" -CSS_ZS_FILE=$(echo $ZS_FILE | sed -e 's/.[^.]*$/.css/') +---@type Stylesheet[] +local stylesheets = { + { + name = "reset", + }, + { + name = "main", + }, + { + name = "content", + lazy = true + }, + { + name = "deco", + lazy = true + } +} -for css in $CSS; do - printf "\n" "$css" -done +---@param path string +---@return string, integer +local function get_file_stem(path) + return path + :gsub(".[^.]*$", "") -- get rid of ext + :gsub(".*/", "") -- get rid of prefix +end -if [ -f $(printf "assets/css/%s" "$CSS_ZS_FILE") ]; then - printf "\n" "$CSS_ZS_FILE" -fi +local current_path = assert(os.getenv("ZS_FILE")) +local current_file = get_file_stem(current_path) + +local f = io.open("assets/css/" .. current_file .. ".page.css") +if f ~= nil then + f:close() + table.insert(stylesheets, { + name = current_file .. ".page" + }) +end + +for _, stylesheet in ipairs(stylesheets) do + local content = [[link rel="stylesheet" href="/assets/css/]] .. stylesheet.name .. [[.css"]] + if stylesheet.lazy then + print("<" .. content .. [[ media="print" onload="this.media='all'; this.onload = null">]]) + print("") + else + print("<" .. content .. ">") + end +end -- cgit v1.2.3