WIP: refactor to shorten line
This commit is contained in:
parent
6680d0c0c5
commit
d854053e34
22
site.moon
22
site.moon
@ -1,7 +1,10 @@
|
|||||||
sitegen = require "sitegen"
|
sitegen = require "sitegen"
|
||||||
lfs = require "lfs"
|
lfs = require "lfs"
|
||||||
|
|
||||||
rootname = (str) -> string.gsub str, "%..+", ""
|
rootname = (str) ->
|
||||||
|
result = string.gsub str, "%..+", ""
|
||||||
|
result
|
||||||
|
|
||||||
last = (list) -> list[#list]
|
last = (list) -> list[#list]
|
||||||
|
|
||||||
split = (str, delimiter="/") ->
|
split = (str, delimiter="/") ->
|
||||||
@ -13,7 +16,22 @@ target = (path, prefix) -> join(prefix, rootname(last(split path)))
|
|||||||
posts = (path=".") ->
|
posts = (path=".") ->
|
||||||
{join(path, file), target(file, "/posts") for file in lfs.dir path when file != "." and file != ".."}
|
{join(path, file), target(file, "/posts") for file in lfs.dir path when file != "." and file != ".."}
|
||||||
|
|
||||||
|
path = "docs"
|
||||||
|
|
||||||
|
names = [file for file in lfs.dir(path) when file != "." and file != ".."]
|
||||||
|
|
||||||
|
tuples = for _, file in ipairs names
|
||||||
|
{join(path, file), target(file, "/posts")}
|
||||||
|
|
||||||
|
new_posts = (path=".") ->
|
||||||
|
t = for _, file in ipairs names
|
||||||
|
{join(path, file), target(file, "/posts")}
|
||||||
|
t
|
||||||
|
|
||||||
|
news = new_posts("docs")
|
||||||
|
posts = {unpack tup for tup in *news}
|
||||||
|
|
||||||
sitegen.create =>
|
sitegen.create =>
|
||||||
@title = "Hello World"
|
@title = "Hello World"
|
||||||
add "index.md"
|
add "index.md"
|
||||||
add path, target: target for path, target in pairs posts "docs"
|
add path, target: target for path, target in pairs posts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user