diff options
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/base.lua | 45 | ||||
-rw-r--r-- | layouts/blog.lua | 8 |
2 files changed, 53 insertions, 0 deletions
diff --git a/layouts/base.lua b/layouts/base.lua new file mode 100644 index 0000000..aae2081 --- /dev/null +++ b/layouts/base.lua @@ -0,0 +1,45 @@ +local navigation_table = { + {'home', '/index.html'}, + {'projects', '/projects/'}, + {'git', '/git'}, + {'about', '/about.html'}, +} + +local navlinks = '' + +for _, link in pairs(navigation_table) do + navlinks = navlinks .. + string.format('<a href="%s">%s</a> ', link[2], link[1]) +end +navlinks = string.sub(navlinks, 1, -4) + +local navigation = string.format('<div id="navigation"><pre>%s</pre></div>', navlinks) + +return function(html, page_tbl) + local html = string.gsub( + html, + '<h1>(.-)</h1>', + '<p class="centered">%1<br>================================</p>' + ) + + local fmt = [[ +<!doctype html> + <html> + <meta charset="utf-8"> + <title>%s</title> + <link rel="stylesheet" href="/style.css"> + </html> + <body> + %s + <div id="content"> + %s + </div> + </body> +</html> +]] +return string.format( + fmt, + string.format('%s | %s', page_tbl.title, argent.config.site_name), + navigation, + html) +end diff --git a/layouts/blog.lua b/layouts/blog.lua new file mode 100644 index 0000000..94dc685 --- /dev/null +++ b/layouts/blog.lua @@ -0,0 +1,8 @@ +local base = require('layouts.base') + +return function(html, page_tbl) + local html = string.format( + '<h1>%s</h1>\n<p class="centered">%s</p>\n\n%s', + page_tbl.title, page_tbl.date, html) + return base(html, page_tbl) +end |