Added generators; modified rules to process news page.
h3rald h3rald@h3rald.com
Sat, 11 Nov 2017 14:01:27 +0100
10 files changed,
152 insertions(+),
5 deletions(-)
M
site/contents/home.md
→
site/contents/home.md
@@ -1,4 +1,5 @@
----- +id: "news" content-type: "page" title: "Home" -----
A
site/contents/news.md
@@ -0,0 +1,6 @@
+----- +id: news +title: "Latest News" +content-type: news +----- +Test...
A
site/contents/posts/v010-released.md
@@ -0,0 +1,10 @@
+----- +id: v010-released +title: "Version 0.1.0 released" +content-type: post +date: "15 October 2017" +timestamp: 1508065200 +----- + +Internal release. +
A
site/contents/posts/v020-released.md
@@ -0,0 +1,10 @@
+----- +id: v020-released +title: "Version 0.2.0 released" +content-type: post +date: "11 November 2017" +timestamp: 1510399624 +----- + +Internal release. +
M
site/rules.min
→
site/rules.min
@@ -12,7 +12,7 @@ ("index" %id)
(".html" %ext) ) tap )) - ((ext ".md" ==) ( + ((true) ( meta ( (".html" %ext) ("$1/index" (id) => % %id)@@ -50,12 +50,19 @@ ) tap
output-fwrite ) :process-css-asset -;Main +;;; Main ;;; + +;Filter and sort posts by timestamp +contents (/content-type "post" ==) filter (=a =b a /timestamp b /timestamp >) sort =posts + +;Process contents contents ( - (dict) expect -> - process-content set-destination output-fwrite + (dict) expect -> =content + content (/id "news" ==) (content posts %posts #content) when + content process-content set-destination output-fwrite ) foreach +;Process assets assets ( (dict) expect -> dup
A
site/scripts/page.min
@@ -0,0 +1,37 @@
+"" :ident +"" :title +false :valid-id + +( + (string) expect first :ident + ident "^[a-z0-9-]+$" match :valid-regexp + (. "contents") => "/" join ls =filelist + filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file + valid-regexp valid-file and +) :validate + + +(valid-id not) ( + "ID" ask @ident + ident validate @valid-id + (valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn) when +) while + +"Title" ask @title + +"----- +id: $1 +title: \"$2\" +content-type: page +----- + +" (ident title) => % :metadata + +metadata puts +("Create page?" confirm) +( + (ident ".md") => "" join :fn + (. "contents") => "/" join :dirpath + (dirpath fn) => "/" join :path + metadata path fwrite +) when
A
site/scripts/post.min
@@ -0,0 +1,42 @@
+"" :ident +"" :title +timestamp :ts +ts "d MMMM yyyy" tformat :date +false :valid-id + +( + (string) expect first :ident + ident "^[a-z0-9-]+$" match :valid-regexp + (. "contents" "posts") => "/" join ls =filelist + filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file + valid-regexp valid-file and +) :validate + + +(valid-id not) ( + "ID" ask @ident + ident validate @valid-id + (valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn) when +) while + +"Title" ask @title + +"----- +id: $1 +title: \"$2\" +content-type: post +date: \"$3\" +timestamp: $4 +----- + +" (ident title date ts) => % :metadata + +metadata puts +("Create post?" confirm) +( + (ident ".md") => "" join :fn + (. "contents" "posts") => "/" join :dirpath + (dirpath exists? not) (dirpath mkdir) when + (dirpath fn) => "/" join :path + metadata path fwrite +) when
M
site/templates/_header.mustache
→
site/templates/_header.mustache
@@ -3,7 +3,7 @@ <input type="checkbox" class="luxbar-checkbox" id="luxbar-checkbox"/>
<div class="luxbar-menu luxbar-menu-right luxbar-menu-dark"> <ul class="luxbar-navigation"> <li class="luxbar-header"> - <a href="#" class="luxbar-brand">{{site-title}}</a> + <a href="/" class="luxbar-brand">{{site-title}}</a> <label class="luxbar-hamburger luxbar-hamburger-doublespin" id="luxbar-hamburger" for="luxbar-checkbox"> <span></span> </label> </li>
A
site/templates/news.mustache
@@ -0,0 +1,19 @@
+<!doctype html> +<html lang="en"> + {{> _head}} + <body> + {{> _header}} + <main> + <article> + <h1>{{title}}</h1> + {{{contents}}} + <ul class="unstyled"> + {{#posts}} + <li> <span class="date">{{date}}</span> — <a href="/{{id}}">{{title}}</a></li> + {{/posts}} + </ul> + </article> + </main> + {{> _footer}} + </body> +</html>
A
site/templates/post.mustache
@@ -0,0 +1,15 @@
+<!doctype html> +<html lang="en"> + {{> _head}} + <body> + {{> _header}} + <main> + <article> + <h1>{{title}}</h1> + <p class="date">{{date}}</p> + {{{contents}}} + </article> + </main> + {{> _footer}} + </body> +</html>