Fix blurb encoding
This commit is contained in:
parent
72b771a0cb
commit
c5c4c493e1
42
site.moon
42
site.moon
@ -50,7 +50,10 @@ reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
|
|||||||
extract_id = (source) -> string.match Path.filename(source), "%a[%w%-]+"
|
extract_id = (source) -> string.match Path.filename(source), "%a[%w%-]+"
|
||||||
extract_date = (source) -> string.match Path.filename(source), "%d+%-%d%d%-%d%d"
|
extract_date = (source) -> string.match Path.filename(source), "%d+%-%d%d%-%d%d"
|
||||||
format_date = (str) -> date(str)\fmt "%b %d, %Y"
|
format_date = (str) -> date(str)\fmt "%b %d, %Y"
|
||||||
publish_date = (path) -> format_date extract_date path
|
|
||||||
|
publish_date = (path using nil) ->
|
||||||
|
date = extract_date path
|
||||||
|
date, format_date date
|
||||||
|
|
||||||
strip_date = (filename) ->
|
strip_date = (filename) ->
|
||||||
filename\gsub "#{escape_patt(extract_date(filename) .. "-")}/?", ""
|
filename\gsub "#{escape_patt(extract_date(filename) .. "-")}/?", ""
|
||||||
@ -75,12 +78,6 @@ 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]
|
||||||
|
|
||||||
listing_info = (page) ->
|
|
||||||
{ :title, :id, publish_date: pub_date, :blurb } = page.meta
|
|
||||||
title = title or titleize_slug id
|
|
||||||
url = rootname page\url_for!
|
|
||||||
{ title: title, publish_date: pub_date, blurb: blurb, url: url }
|
|
||||||
|
|
||||||
get_posts = (limit) =>
|
get_posts = (limit) =>
|
||||||
pages = @site\query_pages { is_a: "post" }
|
pages = @site\query_pages { is_a: "post" }
|
||||||
table.sort pages, (a, b) -> a.source > b.source
|
table.sort pages, (a, b) -> a.source > b.source
|
||||||
@ -93,25 +90,30 @@ sitegen.create =>
|
|||||||
@version = "0.2.12"
|
@version = "0.2.12"
|
||||||
|
|
||||||
@just_render_the_damn_list = (arg={}, _) =>
|
@just_render_the_damn_list = (arg={}, _) =>
|
||||||
posts = [listing_info post for post in *get_posts @, arg.limit]
|
posts = [post for post in *get_posts @, arg.limit]
|
||||||
|
|
||||||
html.build ->
|
html.build ->
|
||||||
import section, h3, time, a from tag
|
import section, h3, time, a from tag
|
||||||
|
|
||||||
[section {
|
return for post in *posts
|
||||||
h3 { a { title, href: url }}
|
{:title, :blurb, :id, publish_date: {iso, pretty}} = post.meta
|
||||||
time { pretty, datetime: iso }
|
url = rootname post\url_for!
|
||||||
"—", blurb, a { "Read post →", class: "read-post-link", href: url }
|
blurb = html.builders.raw!(html.build -> blurb) if blurb
|
||||||
} for { :title, :url, :blurb, publish_date: { iso, pretty }} in *posts]
|
|
||||||
|
section {
|
||||||
|
h3 { a { title or titleize_slug(id), href: url }}
|
||||||
|
time { pretty, datetime: iso }
|
||||||
|
"—", blurb, a { "Read post →", class: "read-post-link", href: url }
|
||||||
|
}
|
||||||
|
|
||||||
add_all = (files) ->
|
add_all = (files) ->
|
||||||
for path in *files
|
add path, {
|
||||||
add path,
|
target: target path, "/posts"
|
||||||
target: target(path, "/posts")
|
template: "post"
|
||||||
template: "post"
|
is_a: "post"
|
||||||
is_a: "post"
|
publish_date: { publish_date path }
|
||||||
publish_date: { extract_date(path), publish_date path }
|
id: extract_id path
|
||||||
id: extract_id path
|
} for path in *files
|
||||||
|
|
||||||
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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user