WIP
This commit is contained in:
parent
e878441819
commit
9eb06e2789
24
site.moon
24
site.moon
@ -43,16 +43,22 @@ rootname = (str) ->
|
|||||||
result = string.gsub str, "%..+", ""
|
result = string.gsub str, "%..+", ""
|
||||||
result
|
result
|
||||||
|
|
||||||
last = (list) -> list[#list]
|
|
||||||
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
|
|
||||||
reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
|
|
||||||
target = (path, prefix) -> join prefix, rootname(last(common.split path, "/"))
|
|
||||||
|
|
||||||
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) -> format_date extract_date path
|
||||||
|
|
||||||
|
last = (list) -> list[#list]
|
||||||
|
join = (first, last, delimiter="/") -> table.concat { first, last }, delimiter
|
||||||
|
reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
|
||||||
|
target = (path, prefix=".") ->
|
||||||
|
|
||||||
|
a = rootname(last(common.split path, "/"))
|
||||||
|
b = a\gsub "#{escape_patt(extract_date(a) .. "-")}/?", ""
|
||||||
|
p b
|
||||||
|
b
|
||||||
|
Path.join prefix, a\gsub("#{escape_patt(extract_date(a) .. "-")}/?", "")
|
||||||
|
|
||||||
h = (word) -> word\sub(1, 1)\upper!
|
h = (word) -> word\sub(1, 1)\upper!
|
||||||
t = (word) -> word\sub(2, -1)\lower!
|
t = (word) -> word\sub(2, -1)\lower!
|
||||||
titleize = (word) -> h(word), t(word)
|
titleize = (word) -> h(word), t(word)
|
||||||
@ -105,9 +111,7 @@ documents = (path=".") ->
|
|||||||
{join(path, file), target(file, "/posts") for file in *files}
|
{join(path, file), target(file, "/posts") for file in *files}
|
||||||
|
|
||||||
clean = (target) ->
|
clean = (target) ->
|
||||||
dirty = extract_date target
|
target\gsub "#{escape_patt(extract_date(target) .. "-")}/?", ""
|
||||||
escaped = dirty\gsub("%-", "%%-") .. "%-"
|
|
||||||
target\gsub(escaped, "")
|
|
||||||
|
|
||||||
sitegen.create =>
|
sitegen.create =>
|
||||||
@site_title = "WebDevCat.me"
|
@site_title = "WebDevCat.me"
|
||||||
@ -116,11 +120,11 @@ sitegen.create =>
|
|||||||
@list_posts = list_posts @, template
|
@list_posts = list_posts @, template
|
||||||
|
|
||||||
add_all = (name, files) ->
|
add_all = (name, files) ->
|
||||||
for path, target in pairs files
|
for path, _ in pairs files
|
||||||
id = extract_id path
|
id = extract_id path
|
||||||
|
|
||||||
add path,
|
add path,
|
||||||
target: clean(target)
|
target: clean(target(path, "/posts"))
|
||||||
template: name
|
template: name
|
||||||
is_a: name
|
is_a: name
|
||||||
publish_date: publish_date path
|
publish_date: publish_date path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user