blob: bbe31ba490b6ed44245c75b9a87548f55c4931ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/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("<noscript><" .. content .. "></noscript>")
else
print("<" .. content .. ">")
end
end
|