Compare commits

...

5 Commits

Author SHA1 Message Date
murat 33540f028f fix page title handling 2026-06-04 20:58:16 +03:00
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
murat 21fcf6702c add md contents to the html files 2026-06-04 02:06:28 +03:00
murat f9d9f5b26a replace markdownFiles.content with md file content 2026-06-04 01:34:45 +03:00
+44 -5
View File
@@ -50,11 +50,19 @@ for index, file in ipairs(markdownFiles) do
fileOptions = fileOptions:sub(fileOptions:find("\n")+1, fileOptions:len())
end
-- fill options table
for i, value in ipairs(lines) do
if value:sub(value:len(), value:len()) == "\n" then
value = value:sub(1, value:find("\n")-1)
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
else
return print(file.filePath .. " file doesn't have a options section!")
@@ -64,19 +72,34 @@ for index, file in ipairs(markdownFiles) do
end
end
-- replace markdownFiles.content with md file content
for index, value in ipairs(markdownFiles) do
local f = io.open(markdownFiles[index].filePath)
if f then
local content = f:read("*a")
f:close()
-- delete options section
content = content:sub(5, content:len())
content = content:sub(content:find("---\n")+4, content:len())
markdownFiles[index].content = content
end
end
for index, value in ipairs(markdownFiles) do
print("---------------")
-- print file path with index
print(index .. ': ' .. markdownFiles[index].filePath)
local f = io.open(markdownFiles[index].filePath, 'r')
if f then
local content = f:read("*all")
f:close()
-- print file content
print(content)
print(markdownFiles[index].content)
-- print file options
print("--- OPTIONS ---")
for i, value in ipairs(markdownFiles[index].options) do
print(markdownFiles[index].options[i])
for key, val in pairs(markdownFiles[index].options) do
print(key .. ": " .. val)
end
print("---------------")
else
@@ -86,6 +109,8 @@ end
-- get index.html content
local indexFile = io.open("index.html"):read("*all")
local siteName
local siteTitle
-- remove and create "public/" directory
lfs.rmdir("public")
@@ -98,6 +123,20 @@ for index, value in ipairs(markdownFiles) do
if htmlFile then
local content = indexFile
-- replace <!-- sitecontents --> with markdown file content
local start_idx, end_idx = content:find("<!-- sitecontents -->", 1, true)
if start_idx and end_idx then
local first = content:sub(1, start_idx - 1)
local second = content:sub(end_idx + 1)
content = first .. markdownFiles[index].content .. second
end
while content:find("<!-- title -->", 1, true) do
start_idx, end_idx = content:find("<!-- title -->", 1, true)
if start_idx and end_idx then
local first = content:sub(1, start_idx - 1)
local second = content:sub(end_idx + 1)
content = first .. markdownFiles[index].options["title"] .. second
end
end
htmlFile:write(content)
htmlFile:close()