Add posts page; fix post templates
This commit is contained in:
parent
5f32456f4b
commit
014a3fd49f
@ -1,3 +1,11 @@
|
|||||||
|
## requirements
|
||||||
|
|
||||||
|
`pandoc` utility must be installed
|
||||||
|
|
||||||
|
- Debian Bookworm:
|
||||||
|
|
||||||
|
$ apt-get update && apt-get install -y pandoc
|
||||||
|
|
||||||
## start default openresty
|
## start default openresty
|
||||||
|
|
||||||
1. Run `docker run --rm -it --init -w /opt -v $PWD:/opt -p 80:80 openresty/openresty:1.27.1.2-0-bookworm-buildpack`
|
1. Run `docker run --rm -it --init -w /opt -v $PWD:/opt -p 80:80 openresty/openresty:1.27.1.2-0-bookworm-buildpack`
|
||||||
@ -33,7 +41,6 @@
|
|||||||
}
|
}
|
||||||
http {
|
http {
|
||||||
server {
|
server {
|
||||||
root /opt/www;
|
|
||||||
listen 8080;
|
listen 8080;
|
||||||
location / {
|
location / {
|
||||||
default_type text/html;
|
default_type text/html;
|
||||||
|
4
blog.html
Normal file
4
blog.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<h2>Posts</h2>
|
||||||
|
|
||||||
|
<!-- render posts -->
|
||||||
|
$render{"posts"}
|
@ -11,3 +11,7 @@ $render{"templates/wares"}
|
|||||||
|
|
||||||
<!-- render posts -->
|
<!-- render posts -->
|
||||||
$render{"posts"}
|
$render{"posts"}
|
||||||
|
|
||||||
|
<h4 style="text-align: center;">
|
||||||
|
<a href="$root/posts">View more posts</a>
|
||||||
|
</h4>
|
||||||
|
35
site.moon
35
site.moon
@ -43,45 +43,18 @@ sitegen.create =>
|
|||||||
@app_name = "stasis"
|
@app_name = "stasis"
|
||||||
@version = "0.2.12"
|
@version = "0.2.12"
|
||||||
|
|
||||||
-- add "test.md"
|
|
||||||
--
|
|
||||||
-- filter "test", (body) =>
|
|
||||||
-- body\gsub "%-%-%-.-%.%.%.", (yaml_header) ->
|
|
||||||
-- moonscript_header = yaml_header\gsub "%-%-%-", "{"
|
|
||||||
-- result = moonscript_header\gsub "%.%.%.", "}"
|
|
||||||
-- result
|
|
||||||
|
|
||||||
add "index.html"
|
add "index.html"
|
||||||
add path, target: out, template: "blog", is_a: "post", post: {
|
add "blog.html", target: "posts/index", template: "blog"
|
||||||
|
|
||||||
|
add path, target: out, template: "post", is_a: "post", post: {
|
||||||
publish_date: publish_date(path)
|
publish_date: publish_date(path)
|
||||||
}, id: extract_id(path) for path, out in pairs posts "docs"
|
}, id: extract_id(path) for path, out in pairs posts "docs"
|
||||||
|
|
||||||
|
-- replace yaml headers with moonscript headers
|
||||||
filter "docs", (body) =>
|
filter "docs", (body) =>
|
||||||
body\gsub "%-%-%-.-%.%.%.", (yaml_header) ->
|
body\gsub "%-%-%-.-%.%.%.", (yaml_header) ->
|
||||||
moonscript_header = yaml_header\gsub "%-%-%-", "{"
|
moonscript_header = yaml_header\gsub "%-%-%-", "{"
|
||||||
result = moonscript_header\gsub "%.%.%.", "}"
|
result = moonscript_header\gsub "%.%.%.", "}"
|
||||||
result
|
result
|
||||||
-- add "docs/2023-11-15-test-mix-task-file-modify.md",
|
|
||||||
-- target: "posts/2023-11-15-test-mix-task-file-modify.html"
|
|
||||||
-- template: "blog"
|
|
||||||
-- is_a: "post"
|
|
||||||
-- post: {
|
|
||||||
-- publish_date: publish_date "docs/2023-11-15-test-mix-task-file-modify.md"
|
|
||||||
-- }
|
|
||||||
-- id: extract_id "docs/2023-11-15-test-mix-task-file-modify.md"
|
|
||||||
|
|
||||||
copy "app.css"
|
copy "app.css"
|
||||||
|
|
||||||
-- filter "test", (body) =>
|
|
||||||
-- require("moon").p body
|
|
||||||
|
|
||||||
-- filter "2023%-08%-03", (body) =>
|
|
||||||
-- print "hello"
|
|
||||||
-- table.concat { body, "<p>hey there</p>" }
|
|
||||||
--
|
|
||||||
-- body\gsub "<h1>.-</h1>", (header) ->
|
|
||||||
-- table.concat { body, "yoyoasdf" }
|
|
||||||
--
|
|
||||||
-- body\gsub "{.-}", (header) ->
|
|
||||||
-- require("moon").p header
|
|
||||||
-- table.concat { '</div>', header, '<div class="main">' }
|
|
||||||
|
@ -10,17 +10,4 @@ $wrap{"root"}
|
|||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<article>
|
|
||||||
<header>
|
|
||||||
<div>
|
|
||||||
<h2>$(title or id)</h2>
|
|
||||||
<time>$(post.publish_date)</time>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
$body
|
$body
|
||||||
|
|
||||||
<div class="mt-16">
|
|
||||||
<a href="/posts">Back to posts</a>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
|
16
templates/post.html
Normal file
16
templates/post.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
$wrap{"blog"}
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<div>
|
||||||
|
<h2>$(title or id)</h2>
|
||||||
|
<time>$(post.publish_date)</time>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
$body
|
||||||
|
|
||||||
|
<div class="mt-16">
|
||||||
|
<a href="/posts">Back to posts</a>
|
||||||
|
</div>
|
||||||
|
</article>
|
Loading…
x
Reference in New Issue
Block a user