Make a titleized slug the default post title
This commit is contained in:
parent
20477d99fb
commit
0bbf998ebb
@ -64,8 +64,7 @@
|
|||||||
|
|
||||||
## todo
|
## todo
|
||||||
|
|
||||||
* titleize slugs
|
* page titles
|
||||||
|
|
||||||
* treesitter highlighting for moonscript
|
* treesitter highlighting for moonscript
|
||||||
* penlight library
|
* penlight library
|
||||||
* sitegen plugins
|
|
||||||
|
13
site.moon
13
site.moon
@ -57,6 +57,15 @@ 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) -> format_date extract_date path
|
||||||
|
|
||||||
|
common = require("sitegen.common")
|
||||||
|
h = (word) -> word\sub(1, 1)\upper!
|
||||||
|
t = (word) -> word\sub(2, -1)\lower!
|
||||||
|
titleize = (word) -> h(word), t(word)
|
||||||
|
|
||||||
|
titleize_slug = (slug) ->
|
||||||
|
words = [{ titleize word } for word in *common.split slug, "-"]
|
||||||
|
[head .. tail for { head, tail } in *words]
|
||||||
|
|
||||||
list_posts = (page, limit) ->
|
list_posts = (page, limit) ->
|
||||||
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
|
||||||
@ -65,7 +74,7 @@ list_posts = (page, limit) ->
|
|||||||
import section, h3, a, time from tag
|
import section, h3, a, time from tag
|
||||||
|
|
||||||
[section {
|
[section {
|
||||||
h3 { a { href: meta.target .. ".html", meta.title or meta.id }}
|
h3 { a { href: meta.target .. ".html", meta.title or titleize_slug meta.id }}
|
||||||
time { publish_date source }
|
time { publish_date source }
|
||||||
{ "—", if meta.blurb then html.builders.text! meta.blurb }
|
{ "—", if meta.blurb then html.builders.text! meta.blurb }
|
||||||
a { class: "read-post-link", href: meta.target .. ".html",
|
a { class: "read-post-link", href: meta.target .. ".html",
|
||||||
@ -73,7 +82,6 @@ list_posts = (page, limit) ->
|
|||||||
}
|
}
|
||||||
} for { meta: meta, source: source } in *posts[1, limit or #posts]]
|
} for { meta: meta, source: source } in *posts[1, limit or #posts]]
|
||||||
|
|
||||||
|
|
||||||
sitegen.create =>
|
sitegen.create =>
|
||||||
@site_title = "WebDevCat.me · Catalin Mititiuc"
|
@site_title = "WebDevCat.me · Catalin Mititiuc"
|
||||||
@app_name = "stasis"
|
@app_name = "stasis"
|
||||||
@ -90,6 +98,7 @@ sitegen.create =>
|
|||||||
is_a: "post"
|
is_a: "post"
|
||||||
publish_date: publish_date(path)
|
publish_date: publish_date(path)
|
||||||
id: extract_id(path)
|
id: extract_id(path)
|
||||||
|
to_title: (slug) -> table.concat titleize_slug(slug), " "
|
||||||
|
|
||||||
-- replace post markdown yaml headers with moonscript headers
|
-- replace post markdown yaml headers with moonscript headers
|
||||||
filter "docs", (body) =>
|
filter "docs", (body) =>
|
||||||
|
@ -3,7 +3,7 @@ $wrap{"blog"}
|
|||||||
<article>
|
<article>
|
||||||
<header>
|
<header>
|
||||||
<div>
|
<div>
|
||||||
<h2>$(title or id)</h2>
|
<h2>$(title or to_title(id))</h2>
|
||||||
<time>$publish_date</time>
|
<time>$publish_date</time>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user