Style refactor and per-post images
This commit is contained in:
parent
f3e175f2f5
commit
8686fd9bae
13 changed files with 62 additions and 31 deletions
3
.luarc.json
Normal file
3
.luarc.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"workspace.checkThirdParty": false
|
||||
}
|
|
@ -15,7 +15,7 @@ dependencies = {
|
|||
"lua-cjson ~> 2.1",
|
||||
"restia",
|
||||
"rgbstr",
|
||||
"scaffold ~> 1.1",
|
||||
"scaffold ~> 1.3.1",
|
||||
"shapeshift ~> 1.1",
|
||||
"skooma",
|
||||
"streamcsv ~> 1.1",
|
||||
|
|
51
build.lua
51
build.lua
|
@ -10,15 +10,22 @@ local atom = require 'feed.atom'
|
|||
local paramparser = require 'paramparser'
|
||||
local params = paramparser(...)
|
||||
package.loaded.params = params
|
||||
local config = require 'config'
|
||||
local pages = require 'pages'
|
||||
local templates = require 'templates'
|
||||
local posts = require 'posts'
|
||||
|
||||
local tree = {}
|
||||
local output_tree = {}
|
||||
|
||||
for i, path in ipairs(params.copy) do
|
||||
scaffold.deep(tree, path, scaffold.readdir(path))
|
||||
for name, content in pairs(scaffold.readdir("static")) do
|
||||
scaffold.deep(output_tree, name, content)
|
||||
end
|
||||
|
||||
local function is_image(name)
|
||||
if name:downcase():match("^.jpg$") then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function render(name, data)
|
||||
|
@ -30,19 +37,39 @@ local function page(name, data)
|
|||
end
|
||||
|
||||
-- Render Posts
|
||||
for idx, post in ipairs(posts) do
|
||||
for _, post in ipairs(posts) do
|
||||
local body = tostring(render("post", post))
|
||||
|
||||
scaffold.deep(tree, post.path, body)
|
||||
scaffold.deep(output_tree, post.path, body)
|
||||
end
|
||||
|
||||
scaffold.deep(tree, "feeds/all.rss.xml", rss(posts))
|
||||
scaffold.deep(tree, "feeds/all.atom.xml", atom(posts))
|
||||
scaffold.deep(output_tree, "feeds/all.rss.xml", rss(posts))
|
||||
scaffold.deep(output_tree, "feeds/all.atom.xml", atom(posts))
|
||||
|
||||
if params.delete then
|
||||
restia.utils.delete(params.output)
|
||||
end
|
||||
|
||||
do -- Copy blog images
|
||||
local function iter_files(tree, callback)
|
||||
if getmetatable(tree) == scaffold.lazy then
|
||||
callback(tree)
|
||||
else
|
||||
for _, node in pairs(tree) do
|
||||
iter_files(node, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
iter_files(scaffold.readdir("posts", {files = "lazy"}), function(file)
|
||||
local name = file.path:match("[^/]+$")
|
||||
if name:find(".jpg$") then
|
||||
local path = "/images/" .. name
|
||||
scaffold.deep(output_tree, path, file)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function transform(tab)
|
||||
return function(data)
|
||||
local success, result = shapeshift.table(tab, "keep")(data)
|
||||
|
@ -53,7 +80,7 @@ end
|
|||
local function drop() return true, nil end
|
||||
|
||||
-- Generate Post Metadata
|
||||
tree["posts.json"] = json.encode(
|
||||
output_tree["posts.json"] = json.encode(
|
||||
fun
|
||||
.iter(posts)
|
||||
:map(transform {
|
||||
|
@ -63,10 +90,10 @@ tree["posts.json"] = json.encode(
|
|||
:totable()
|
||||
)
|
||||
|
||||
tree["index.html"] = tostring(page("index", tree["posts.json"]))
|
||||
output_tree["index.html"] = tostring(page("index", output_tree["posts.json"]))
|
||||
|
||||
if params.cname then
|
||||
tree.CNAME = params.cname
|
||||
output_tree.CNAME = params.cname
|
||||
end
|
||||
|
||||
scaffold.builddir(params.output, tree)
|
||||
scaffold.builddir(params.output, output_tree)
|
||||
|
|
|
@ -6,7 +6,6 @@ return function(...)
|
|||
local parse = arrr {
|
||||
{ "Output directory", "--output", "-o", 'directory' };
|
||||
{ "Input directory", "--input", "-i", 'directory' };
|
||||
{ "Copy directory", "--copy", "-c", 'directory', 'repeatable' };
|
||||
{ "Include unpublished posts", "--unpublished", "-u", nil };
|
||||
{ "Set the github pages CNAME", "--cname", nil, 'domain' };
|
||||
{ "Delete everything first", "--delete", "-d" };
|
||||
|
|
|
@ -7,11 +7,11 @@ local string = require 'stringplus'
|
|||
|
||||
local function parsedate(date)
|
||||
local year, month, day = date:match("(%d+)%-(%d+)%-(%d+)")
|
||||
return os.time {
|
||||
year = tonumber(year);
|
||||
month = tonumber(month);
|
||||
day = tonumber(day);
|
||||
}
|
||||
return os.time {
|
||||
year = tonumber(year) or error("Invalid date string: " .. date);
|
||||
month = tonumber(month) or error("Invalid date string: " .. date);
|
||||
day = tonumber(day) or error("Invalid date string: " .. date);
|
||||
}
|
||||
end
|
||||
|
||||
local validate_head do
|
||||
|
|
|
@ -19,7 +19,6 @@ return function(tags)
|
|||
end
|
||||
return {
|
||||
html.flexRow(list);
|
||||
html.verticalSpacer();
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ post = =>
|
|||
color = table.concat({rgbstr.bytes(@head.tags[1], 16, .3, .5)}, " ")
|
||||
flexColumn class: "info box", style: "--color: rgb(#{color})"
|
||||
* h2 a(@head.title, href: @head.uri), style: "view-transition-name: #{@head.slug}"
|
||||
* small time is: 'local-date', datetime: @head.date, @head.date
|
||||
* p @head.description
|
||||
* tags(@head.tags)
|
||||
* time is: 'local-date', datetime: @head.date, @head.date
|
||||
* @head.description
|
||||
|
||||
slots.head title "Talia's Blog"
|
||||
|
||||
|
@ -23,7 +23,7 @@ slots.head
|
|||
slots.head script type: 'module', src: "/javascript/LocalDate.js"
|
||||
slots.head script type: 'module', src: "/javascript/BlogPost.js"
|
||||
|
||||
return main
|
||||
return article
|
||||
class: "content-width"
|
||||
* h1 "Blog Posts"
|
||||
* [blogPost post p for p in *posts]
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
@import url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/all.css') layer(framework);
|
||||
@import url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/drop-in.css') layer(framework);
|
||||
|
||||
blog-post[hidden] {
|
||||
display: none;
|
||||
}
|
|
@ -25,7 +25,7 @@ task.build {
|
|||
[[
|
||||
export LUA_PATH='%s'
|
||||
export LUA_CPATH='%s'
|
||||
lua build.lua --copy css --copy javascript --output blog --cname blog.but.gay
|
||||
lua build.lua --output blog --cname blog.but.gay
|
||||
]],
|
||||
path, cpath
|
||||
)
|
||||
|
|
|
@ -2,19 +2,21 @@ import output from require 'params'
|
|||
import slotty from require 'skooma'
|
||||
import 'config'
|
||||
|
||||
slots = slotty!
|
||||
|
||||
styles = [[
|
||||
@import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');
|
||||
|
||||
@view-transition { navigation: auto; }
|
||||
|
||||
:root { container: style; }
|
||||
:is(h1, h2, h3, h4, h5, h6) { font-family: "Raleway", sans-serif; }
|
||||
:is(code, kbd, var, samp) { font-family: "Fira Code", monospace; }
|
||||
.badge { font-family: "Open Sans", sans-serif }
|
||||
]]
|
||||
|
||||
slots = slotty!
|
||||
|
||||
slots.footer aside id: "contact"
|
||||
* h2 "Social"
|
||||
* p
|
||||
|
@ -26,7 +28,7 @@ slots.footer aside id: "git"
|
|||
* h2 "Git"
|
||||
* ul
|
||||
* li a "Github", href: "https://github.com/darkwiiplayer"
|
||||
* li a "Gitea", href: "https://git.but.gay/darkwiiplayer"
|
||||
* li a "Forgejo", href: "https://git.but.gay/darkwiiplayer"
|
||||
|
||||
slots.footer aside id: "platforms"
|
||||
* h2 "Federated cloud"
|
||||
|
@ -44,8 +46,6 @@ html
|
|||
* meta name: "view-transition", content: "same-origin"
|
||||
* meta charset: "UTF-8"
|
||||
* meta name: "viewport", content: "width=device-width"
|
||||
* css 'https://darkwiiplayer.github.io/css/all.css'
|
||||
* css 'https://darkwiiplayer.github.io/css/schemes/talia.css'
|
||||
* css "/css/site.css"
|
||||
* style styles
|
||||
* slots.head
|
||||
|
@ -54,7 +54,7 @@ html
|
|||
* slots.top
|
||||
* header class: 'sticky', style: "view-transition-name: header"
|
||||
* h1 "Talia's Blog"
|
||||
* nav { class: 'right bar' }
|
||||
* nav { class: 'right underlined bar' }
|
||||
* ul li a "Home", href: "/"
|
||||
* main
|
||||
* content slots, data
|
||||
|
|
|
@ -41,7 +41,7 @@ else
|
|||
slots.summary div post.head.description, class: "summary", tabindex: 0
|
||||
slots.summary verticalSpacer
|
||||
|
||||
slots.banner aside class: { 'box' }
|
||||
slots.banner aside class: { 'floating box' }, stripe: "rebeccapurple"
|
||||
* b "Hey there!"
|
||||
* p raw [[
|
||||
This blog doesn't use any tracking. When you open this page, I don't see
|
||||
|
|
Loading…
Reference in a new issue