diff --git a/site.moon b/site.moon
index a6b2dcb..19714eb 100644
--- a/site.moon
+++ b/site.moon
@@ -63,9 +63,9 @@ titleize_slug = (slug="") ->
template = [[
$title
+ $title
— $blurb
- Read post →
+ Read post →
$target
]] --- or like this: $(get_posts({limit = 5}))[[$target
]] +-- call like this from a template: $(get_posts())[[$title
]] +-- or like this: $(get_posts({limit = 5}))[[$title
]] get_posts = (args={}) => - posts = @site\query_pages { is_a: "post" } - table.sort posts, (a, b) -> a.source > b.source + pages = @site\query_pages { is_a: "post" } + table.sort pages, (a, b) -> a.source > b.source + limit = math.min args.limit or #pages, #pages + + return for page in *pages[1, limit] + page.target = page.meta.target + { title: title, id: id, publish_date: date, blurb: blurb } = page.meta - return for { meta: meta, source: source } in *posts[1, args.limit or #posts] { - target: meta.target - post_title: meta.title or titleize_slug meta.id - publish_date: publish_date source - blurb: meta.blurb + title: title or titleize_slug id + publish_date: date + blurb: blurb + url: page\url_for! } -- replace '$if' helper function with cosmo's 'cif' @@ -114,23 +124,20 @@ sitegen.create => @list_posts = list_posts @get_posts = get_posts - add "index.html", title: "Catalin Mititiuc", blah: {{say: "wan"},{say: "tuu"}} + add_all = (name="", files) -> + for path, target in pairs files + id = extract_id path + + add path, + target: Path.join Path.basepath(target), id -- TODO reformat target + template: name + is_a: name + publish_date: publish_date path + id: id + + add "index.html", title: "Catalin Mititiuc" add "blog.html", title: "Posts", target: "posts/index", template: "blog" - - -- add "about.html", some: { - -- { one: "alpha", two: "beta" }, - -- { one: "A", two: "B" } - -- }, cif: cosmo.cif, math: math, x: 2 - - for path, target in pairs documents "docs" - id = extract_id path - - add path, - target: Path.join Path.basepath(target), id - template: "post" - is_a: "post" - publish_date: publish_date path - id: id + add_all "post", documents "docs" -- replace post markdown yaml headers with moonscript headers filter "docs", (body) =>