diff options
| author | delta <darkussdelta@gmail.com> | 2026-07-25 11:42:01 +0200 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2026-07-25 11:43:48 +0200 |
| commit | 95ceed33d3adec472f4a1b5d3517baf645766e44 (patch) | |
| tree | 94d8779483e49f7afe624a15e9d271e6f8fbe430 /.zs/styles | |
| parent | ae36b044f1fc36cd5587b0d3111c2ee72cf0c03f (diff) | |
site rework!!
Diffstat (limited to '.zs/styles')
| -rwxr-xr-x | .zs/styles | 58 |
1 files changed, 48 insertions, 10 deletions
@@ -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 "<link rel=\"stylesheet\" href=\"/assets/css/%s.css\">\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 "<link rel=\"stylesheet\" href=\"/assets/css/%s\">\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("<noscript><" .. content .. "></noscript>") + else + print("<" .. content .. ">") + end +end |
