diff --git a/lint_config.lua b/lint_config.lua new file mode 100644 index 0000000..685627c --- /dev/null +++ b/lint_config.lua @@ -0,0 +1,7 @@ +return { + whitelist_globals = { + ["site.moon"] = { + "add" + } + } +} diff --git a/lint_config.moon b/lint_config.moon new file mode 100644 index 0000000..1dd5ac0 --- /dev/null +++ b/lint_config.moon @@ -0,0 +1,7 @@ +{ + whitelist_globals: { + ["site.moon"]: { + "add" + } + } +} diff --git a/site.moon b/site.moon index 82c21c3..bdc4383 100644 --- a/site.moon +++ b/site.moon @@ -1,48 +1,19 @@ sitegen = require "sitegen" lfs = require "lfs" -moon = require "moon" -path = "docs" -files = ["#{path}/#{file}" for file in lfs.dir(path) when file != "." and file != ".."] +files = (path="docs") -> + ["#{path}/#{file}" for file in lfs.dir(path) when file != "." and file != ".."] --- example = "an example string" -example = "docs/post1.md" -split_path = [capture for capture in string.gmatch(example, "[^/]+")] --- moon.p [name for i, name in ipairs split_path when i == #split_path] -filename = split_path[#split_path] --- moon.p string.gsub(filename, ".md", "") -name = string.gsub(filename, ".md", "") - -attrdir = (path) -> - for file in lfs.dir(path) - if file != "." and file != ".." - f = path .. '/' .. file - print f - attr = lfs.attributes f - assert type(attr) == "table" - attrdir f if attr.mode == "directory" - --- attrdir "docs" +rootname = (str) -> string.gsub str, "%.+", "" +last = (list) -> list[#list] split = (str, delimiter) -> - [capture for capture in string.gmatch(str, "[^#{delimiter}]+")] + [capture for capture in string.gmatch str, "[^#{delimiter}]+"] -last = (list) -> list[#list] -rootname = (str) -> string.gsub str, "%.+", "" - -target = (file, delimeter="/") -> - "/posts/#{rootname(last(split(file, delimeter)))}" +target = (path, delimeter="/") -> + "/posts/#{rootname(last(split(path, delimeter)))}" sitegen.create => @title = "Hello World" add "index.md" - add file, target: target file for _, file in ipairs files - - -- add file, target: "/posts/#{rootname(last(split(file, delimeter)))}" for _, file in ipairs files - - -- for _, file in ipairs files - -- split_path = split file, delimiter - -- filename = last split_path - -- name = rootname filename - -- add file, target: "/posts/#{rootname}" - -- add file, target: "/posts/#{rootname(last(split(file, delimeter)))}" + add path, target: target(path) for _, path in ipairs files!