WIP: i think i got it
This commit is contained in:
parent
52342a77e5
commit
d5197a0a58
@ -1,11 +1,3 @@
|
|||||||
<h2>Posts</h2>
|
<h2>Posts</h2>
|
||||||
|
|
||||||
$lp
|
$lp
|
||||||
|
|
||||||
$list_posts[[
|
|
||||||
<section>
|
|
||||||
<h3><a href="$target">$post_title</a></h3>
|
|
||||||
<time>$publish_date</time> — $blurb
|
|
||||||
<a class="read-post-link" href="$target">Read post →</a>
|
|
||||||
</section>
|
|
||||||
]]
|
|
||||||
|
@ -6,13 +6,7 @@ $render{"templates/wares"}
|
|||||||
|
|
||||||
<h2>Posts</h2>
|
<h2>Posts</h2>
|
||||||
|
|
||||||
$list_posts{limit = 5}[[
|
$lp{limit = 5}
|
||||||
<section>
|
|
||||||
<h3><a href="$target">$post_title</a></h3>
|
|
||||||
<time>$publish_date</time> — $blurb
|
|
||||||
<a class="read-post-link" href="$target">Read post →</a>
|
|
||||||
</section>
|
|
||||||
]]
|
|
||||||
|
|
||||||
<h4 style="text-align: center;">
|
<h4 style="text-align: center;">
|
||||||
<a href="$root/posts">View more posts</a>
|
<a href="$root/posts">View more posts</a>
|
||||||
|
31
site.moon
31
site.moon
@ -5,6 +5,7 @@ html = require "sitegen.html"
|
|||||||
cosmo = require "sitegen.cosmo"
|
cosmo = require "sitegen.cosmo"
|
||||||
date = require "date"
|
date = require "date"
|
||||||
|
|
||||||
|
html_renderer = require "sitegen.renderers.html"
|
||||||
import tag from html
|
import tag from html
|
||||||
import escape_patt from require "sitegen.common"
|
import escape_patt from require "sitegen.common"
|
||||||
import p from require "moon"
|
import p from require "moon"
|
||||||
@ -76,7 +77,7 @@ titleize = (word) -> h(word), t(word)
|
|||||||
|
|
||||||
titleize_slug = (slug) ->
|
titleize_slug = (slug) ->
|
||||||
words = [{ titleize word } for word in *common.split slug, "-"]
|
words = [{ titleize word } for word in *common.split slug, "-"]
|
||||||
table.concat [head .. tail for { head, tail } in *words]
|
table.concat [head .. tail for { head, tail } in *words], " "
|
||||||
|
|
||||||
template = [[
|
template = [[
|
||||||
<section>
|
<section>
|
||||||
@ -86,29 +87,16 @@ template = [[
|
|||||||
</section>
|
</section>
|
||||||
]]
|
]]
|
||||||
|
|
||||||
list_posts = (page, limit) ->
|
list_posts = (page, args={}) ->
|
||||||
posts = page.site\query_pages { is_a: "post" }
|
posts = page.site\query_pages { is_a: "post" }
|
||||||
table.sort posts, (a, b) -> a.source > b.source
|
table.sort posts, (a, b) -> a.source > b.source
|
||||||
|
|
||||||
table.concat [cosmo.f(template) {
|
table.concat [common.fill_ignoring_pre template, {
|
||||||
target: meta.target
|
target: meta.target
|
||||||
post_title: meta.title or titleize_slug meta.id
|
post_title: meta.title or titleize_slug meta.id
|
||||||
publish_date: publish_date source
|
publish_date: publish_date source
|
||||||
blurb: meta.blurb
|
blurb: meta.blurb
|
||||||
} for { meta: meta, source: source } in *posts[1, limit or #posts]]
|
} for { meta: meta, source: source } in *posts[1, args.limit or #posts]]
|
||||||
-- html.build ->
|
|
||||||
-- import section, h3, a, time from tag
|
|
||||||
--
|
|
||||||
-- [section {
|
|
||||||
-- h3 { a { href: meta.target, meta.title or titleize_slug meta.id }}
|
|
||||||
-- time { publish_date source }
|
|
||||||
-- { "—", if meta.blurb then html.builders.text! meta.blurb }
|
|
||||||
-- a { class: "read-post-link", href: meta.target,
|
|
||||||
-- "Read post →"
|
|
||||||
-- }
|
|
||||||
-- } for { meta: meta, source: source } in *posts[1, limit or #posts]]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list_posts2 = (page, args={}) ->
|
list_posts2 = (page, args={}) ->
|
||||||
pages = page.site\query_pages { is_a: "post" }
|
pages = page.site\query_pages { is_a: "post" }
|
||||||
@ -123,7 +111,6 @@ list_posts2 = (page, args={}) ->
|
|||||||
|
|
||||||
for post in *posts do cosmo.yield post
|
for post in *posts do cosmo.yield post
|
||||||
|
|
||||||
html_renderer = require "sitegen.renderers.html"
|
|
||||||
html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block
|
html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block
|
||||||
html_renderer.cosmo_helpers.titleize = (slug) => html.build ->
|
html_renderer.cosmo_helpers.titleize = (slug) => html.build ->
|
||||||
titleize_slug(slug) if slug
|
titleize_slug(slug) if slug
|
||||||
@ -138,10 +125,10 @@ sitegen.create =>
|
|||||||
add "index.html", title: "Catalin Mititiuc"
|
add "index.html", title: "Catalin Mititiuc"
|
||||||
add "blog.html", title: "Posts", target: "posts/index", template: "blog"
|
add "blog.html", title: "Posts", target: "posts/index", template: "blog"
|
||||||
|
|
||||||
add "about.html", some: {
|
-- add "about.html", some: {
|
||||||
{ one: "alpha", two: "beta" },
|
-- { one: "alpha", two: "beta" },
|
||||||
{ one: "A", two: "B" }
|
-- { one: "A", two: "B" }
|
||||||
}, cif: cosmo.cif, math: math, x: 2
|
-- }, cif: cosmo.cif, math: math, x: 2
|
||||||
|
|
||||||
for path, target in pairs posts "docs"
|
for path, target in pairs posts "docs"
|
||||||
id = extract_id path
|
id = extract_id path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user