#!/usr/bin/lua ---@class Stylesheet ---@field name string ---@field lazy? boolean ---@type Stylesheet[] local stylesheets = { { name = "reset", }, { name = "main", }, { name = "content", lazy = true }, { name = "deco", lazy = true } } ---@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 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