Compare commits

...

2 Commits

Author SHA1 Message Date
murat 80a8119f6a replace sitename and sitetitle 2026-06-04 20:27:26 +03:00
murat 8b43950cce proper options handling 2026-06-04 20:17:42 +03:00
+23 -4
View File
@@ -54,7 +54,14 @@ for index, file in ipairs(markdownFiles) do
if value:sub(value:len(), value:len()) == "\n" then if value:sub(value:len(), value:len()) == "\n" then
value = value:sub(1, value:find("\n")-1) value = value:sub(1, value:find("\n")-1)
end end
markdownFiles[index].options[i] = value local colonPos = value:find(":")
if colonPos then
local key = value:sub(1, colonPos - 1):match("^%s*(.-)%s*$")
local val = value:sub(colonPos + 1):match("^%s*(.-)%s*$")
if key and key ~= "" then
markdownFiles[index].options[key] = val
end
end
end end
else else
return print(file.filePath .. " file doesn't have a options section!") return print(file.filePath .. " file doesn't have a options section!")
@@ -90,8 +97,8 @@ for index, value in ipairs(markdownFiles) do
print(markdownFiles[index].content) print(markdownFiles[index].content)
-- print file options -- print file options
print("--- OPTIONS ---") print("--- OPTIONS ---")
for i, value in ipairs(markdownFiles[index].options) do for key, val in pairs(markdownFiles[index].options) do
print(markdownFiles[index].options[i]) print(key .. ": " .. val)
end end
print("---------------") print("---------------")
else else
@@ -106,7 +113,19 @@ local siteTitle
for i, v in ipairs(markdownFiles) do for i, v in ipairs(markdownFiles) do
if v.fileName == "index" then if v.fileName == "index" then
-- get siteName and siteTitle -- replace sitename and sitetitle
local start_idx, end_idx = indexFile:find("<!-- sitetitle -->", 1, true)
if start_idx and end_idx then
local first = indexFile:sub(1, start_idx - 1)
local second = indexFile:sub(end_idx + 1)
indexFile = first .. markdownFiles[i].options["sitetitle"] .. second
end
start_idx, end_idx = indexFile:find("<!-- sitename -->", 1, true)
if start_idx and end_idx then
local first = indexFile:sub(1, start_idx - 1)
local second = indexFile:sub(end_idx + 1)
indexFile = first .. markdownFiles[i].options["sitename"] .. second
end
end end
end end