Don't try to access globals

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 20:18:05 -07:00
parent 11d4b97035
commit b89683133d

View File

@ -6,7 +6,6 @@ common = require "sitegen.common"
cosmo = require "sitegen.cosmo"
date = require "date"
html_renderer = require "sitegen.renderers.html"
import tag from html
import escape_patt from require "sitegen.common"
import p from require "moon" -- debug
@ -51,13 +50,13 @@ extract_id = (source) -> string.match Path.filename(source), "%a[%w%-]+"
extract_date = (source) -> string.match Path.filename(source), "%d+%-%d%d%-%d%d"
format_date = (str) -> date(str)\fmt "%b %d, %Y"
publish_date = (path using nil) ->
date = extract_date path
date, format_date date
strip_date = (filename) ->
filename\gsub "#{escape_patt(extract_date(filename) .. "-")}/?", ""
publish_date = (path using extract_date, format_date) ->
date = extract_date path
date, format_date date
target = (path, prefix=".") ->
filename = rootname last common.split path, "/"
Path.join prefix, strip_date filename
@ -70,9 +69,6 @@ titleize_slug = (slug="") ->
words = [{ titleize word } for word in *common.split slug, "-"]
table.concat [head .. tail for { head, tail } in *words], " "
-- replace '$if' helper function with cosmo's 'cif'
html_renderer.cosmo_helpers.if = (args, has_block) => cosmo.cif args, has_block
files_from = (path=".") ->
[Path.join path, file for file in *reverse get_files path]
@ -86,7 +82,10 @@ sitegen.create =>
@site_title = "WebDevCat.me"
@app_name = "stasis"
@version = "0.2.12"
-- helpers
@titleize = (slug) => titleize_slug slug
@cif = (args, has_block) => cosmo.cif args, has_block
@just_render_the_damn_list = (arg={}, _) =>
posts = [post for post in *get_posts @, arg.limit]
@ -97,7 +96,7 @@ sitegen.create =>
return for post in *posts
{:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta
url = rootname post\url_for!
blurb = html.builders.raw!(html.build -> blurb) if blurb
if blurb then blurb = html.builders.raw! blurb
section {
h3 { a { title or titleize_slug(id), href: url }}