Split templates into templates and pages
This commit is contained in:
parent
13121e0481
commit
dbaf7e963c
4 changed files with 20 additions and 8 deletions
12
build.lua
12
build.lua
|
@ -39,6 +39,11 @@ local templates = restia.config.bind('templates', {
|
|||
})
|
||||
package.loaded.templates = templates
|
||||
|
||||
local pages = restia.config.bind('pages', {
|
||||
(require 'restia.config.skooma');
|
||||
})
|
||||
package.loaded.pages = pages
|
||||
|
||||
-- General purpose utility functions
|
||||
|
||||
local function split(str, pattern)
|
||||
|
@ -117,6 +122,9 @@ end)
|
|||
local function render(name, ...)
|
||||
return templates.main(templates[name], ...)
|
||||
end
|
||||
local function page(name, ...)
|
||||
return templates.main(pages[name], ...)
|
||||
end
|
||||
|
||||
-- Render Posts
|
||||
for idx, post in ipairs(posts) do
|
||||
|
@ -125,8 +133,6 @@ for idx, post in ipairs(posts) do
|
|||
restia.utils.deepinsert(tree, post.path, body)
|
||||
end
|
||||
|
||||
tree["index.html"] = render("index", posts)
|
||||
|
||||
if params.delete then
|
||||
restia.utils.delete(params.output)
|
||||
end
|
||||
|
@ -151,4 +157,6 @@ tree["posts.json"] = json.encode(
|
|||
:totable()
|
||||
)
|
||||
|
||||
tree["index.html"] = page("index", posts, tree["posts.json"])
|
||||
|
||||
restia.utils.builddir(params.output, tree)
|
||||
|
|
1
pages/Tupfile
Normal file
1
pages/Tupfile
Normal file
|
@ -0,0 +1 @@
|
|||
include_rules
|
9
pages/index.skooma.yue
Normal file
9
pages/index.skooma.yue
Normal file
|
@ -0,0 +1,9 @@
|
|||
import output from require 'params'
|
||||
|
||||
link = =>
|
||||
a @title, href: "/"..output..@uri
|
||||
|
||||
(json) => (ul [li link post.head, prefix for post in *@]), {
|
||||
title "Index"
|
||||
script "window.posts = JSON.parse(`#{json}`)"
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import output from require 'params'
|
||||
|
||||
link = =>
|
||||
a @title, href: "/"..output..@uri
|
||||
|
||||
(prefix) => ul [li link post.head, prefix for post in *@], title "Index"
|
Loading…
Reference in a new issue