WIP
This commit is contained in:
parent
7e27d00ca4
commit
ef47f48002
@ -2,6 +2,8 @@
|
|||||||
date: "Thu May 08 2025 19:41:30.000000000"
|
date: "Thu May 08 2025 19:41:30.000000000"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$test{ limit = "is this?" }[[what $limit]][[second $limit]]
|
||||||
|
|
||||||
$render{"templates/wares"}
|
$render{"templates/wares"}
|
||||||
|
|
||||||
<h2>Posts</h2>
|
<h2>Posts</h2>
|
||||||
|
37
site.moon
37
site.moon
@ -112,11 +112,48 @@ html_renderer.cosmo_helpers.titleize = (slug) => titleize_slug slug
|
|||||||
files_from = (path=".") ->
|
files_from = (path=".") ->
|
||||||
[Path.join path, file for file in *reverse get_files path]
|
[Path.join path, file for file in *reverse get_files path]
|
||||||
|
|
||||||
|
test = (args, has_block) =>
|
||||||
|
p args
|
||||||
|
p has_block
|
||||||
|
-- if has_block then cosmo.yield {limit: args[1]} else args[1]
|
||||||
|
args._template = 2
|
||||||
|
cosmo.yield(args)
|
||||||
|
-- html = @site\get_renderer "sitegen.renderers.html"
|
||||||
|
-- page\merge_meta vals
|
||||||
|
-- page.tpl_scope = page.meta
|
||||||
|
-- page.template_stack = common.Stack!
|
||||||
|
-- html\render page, assert args[1] or template, "missing html string"
|
||||||
|
nil
|
||||||
|
|
||||||
|
-- use in templates
|
||||||
|
-- $list2{[[<p>$title</p>]], limit = 2}
|
||||||
|
-- $each{$list2({limit = 3}), "item"}[[$item]]
|
||||||
|
list2 = (args={}) =>
|
||||||
|
pages = @site\query_pages { is_a: "post" }
|
||||||
|
table.sort pages, (a, b) -> a.source > b.source
|
||||||
|
limit_or_page_count = math.min args.limit or #pages, #pages
|
||||||
|
|
||||||
|
result = for page in *pages[1, limit_or_page_count]
|
||||||
|
{ :title, :id, publish_date: pub_date, :blurb } = page.meta
|
||||||
|
title = title or titleize_slug id
|
||||||
|
url = rootname page\url_for!
|
||||||
|
vals = { title: title, publish_date: pub_date, blurb: blurb, url: url }
|
||||||
|
|
||||||
|
html = page.site\get_renderer "sitegen.renderers.html"
|
||||||
|
page\merge_meta vals
|
||||||
|
page.tpl_scope = page.meta
|
||||||
|
page.template_stack = common.Stack!
|
||||||
|
html\render page, assert args[1] or template, "missing html string"
|
||||||
|
|
||||||
|
return if args[1] then table.concat result else result
|
||||||
|
|
||||||
sitegen.create =>
|
sitegen.create =>
|
||||||
@site_title = "WebDevCat.me"
|
@site_title = "WebDevCat.me"
|
||||||
@app_name = "stasis"
|
@app_name = "stasis"
|
||||||
@version = "0.2.12"
|
@version = "0.2.12"
|
||||||
@list_posts = list_posts @, template
|
@list_posts = list_posts @, template
|
||||||
|
@test = test
|
||||||
|
@list2 = list2
|
||||||
|
|
||||||
add_all = (files) ->
|
add_all = (files) ->
|
||||||
for path in *files
|
for path in *files
|
||||||
|
Loading…
x
Reference in New Issue
Block a user