WIP: templates

This commit is contained in:
Catalin Constantin Mititiuc 2025-05-10 14:37:19 -07:00
parent b0e3dbcdcf
commit 2f94fd51ae
4 changed files with 18 additions and 20 deletions

View File

@ -4,6 +4,4 @@
## Posts ## Posts
$render{"test"}
- [recursive]($root/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html) - [recursive]($root/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html)

View File

@ -1,7 +1,7 @@
sitegen = require "sitegen" sitegen = require "sitegen"
lfs = require "lfs"
tools = require "sitegen.tools" tools = require "sitegen.tools"
site = require "sitegen.site" site = require "sitegen.site"
lfs = require "lfs"
rootname = (str) -> rootname = (str) ->
result = string.gsub str, "%..+", "" result = string.gsub str, "%..+", ""
@ -18,22 +18,9 @@ posts = (path=".") ->
files = [file for file in lfs.dir path when file != "." and file != ".."] files = [file for file in lfs.dir path when file != "." and file != ".."]
{join(path, file), target(file, "/posts") for _, file in ipairs files} {join(path, file), target(file, "/posts") for _, file in ipairs files}
-- renderer = require "sitegen.renderers.html"
-- Change output dir to what Openresty prefers -- Change output dir to what Openresty prefers
-- site = site! site = site!
-- site.config.out_dir = "html/" site.config.out_dir = "html/"
-- oof = site!
-- templates = site.templates
-- require"moon".p [k for k,v in pairs templates]
-- require"moon".p [k for k,v in pairs site.templates]
-- require"moon".p templates
-- require"moon".p renderer.Renderer.can_load("test.md")
-- require"moon".p renderer\helpers!
css = tools.system_command "cat < %s > %s", "css" css = tools.system_command "cat < %s > %s", "css"
@ -41,8 +28,8 @@ sitegen.create =>
@title = "Hello World" @title = "Hello World"
@app_name = "stasis" @app_name = "stasis"
@version = "0.2.12" @version = "0.2.12"
add "index.md"
add path, target: target for path, target in pairs posts "docs"
add "index.md"
add path, target: out, template: "blog" for path, out in pairs posts "docs"
build css, "app.css" build css, "app.css"

11
templates/blog.html Normal file
View File

@ -0,0 +1,11 @@
$render{"templates/root"}
<section>
<h2><a href="$root/posts/">Web Log</a></h2>
<p>Elixir, JavaScript, SVG, Containers, Git, Linux</p>
<p>
Questions, comments, feedback? <a href="mailto:webdevcat@proton.me">Contact the author</a>.
</p>
</section>
$body

View File

@ -1,3 +1,5 @@
$render{"templates/root"}
<main> <main>
$body $body
</main> </main>