Implemented tag page generation.
h3rald h3rald@h3rald.com
Sun, 06 Aug 2017 17:49:12 +0200
2 files changed,
57 insertions(+),
1 deletions(-)
M
rules.min
→
rules.min
@@ -2,6 +2,7 @@ 'hastysite import
() =TAGS () =TAGCOLUMNS +() =ARCHIVES ; Populates the TAGCOLUMNS array containing tags in groups@@ -34,12 +35,17 @@ ) when
) foreach ) :prepare-tag-data +; Utility operator to format a timestamp into a date +( + int "dddd, d MMMM yyyy" tformat +) :to-date + ; Create the Tags page. ( () "tags/index" %id - "tags" %path + "tags.html" %path ".html" %ext "Tags" %title "page" %content-type@@ -50,6 +56,49 @@ output-fwrite
) :create-tags-page +; Create a page for a specific tag +( + (quot) expect -> =tagdata + tagdata first :tag + tagdata last =articles + articles + articles ( + ((/timestamp swap /timestamp >) sort) + ((dup /timestamp to-date %date) map) + ) tap #articles + () + "tags/$1/index" (tag) => % %id + "tags/$1.html" (tag) => % %path + tag %tag + ".html" %ext + "page" %content-type + "Tag: $1" (tag) => % %title + articles %articles + articles size %count + dup "_tag" swap mustache %contents + dup "page" swap mustache %contents + output-fwrite +) :create-tag-page + + + +; Group articles by month +;( +; (dict) expect -> =article +; article /timestamp :ts +; ts "dddd, d MMMM yyyy" tformat :date +; ts "yyyyMM" tformat :archive +; ts "MMMM yyyy" tformat :month +; (ARCHIVES archive dhas?) +; ( +; +; ) +; ( +; +; ) if +;) :process-timestamp + + ; Group articles by tags ( (dict) expect -> =content@@ -113,6 +162,7 @@
contents (process-tags process-content output-fwrite) foreach prepare-tag-data create-tags-page +TAGS 'create-tag-page foreach ; Process all assets.
A
templates/_tag.mustache
@@ -0,0 +1,6 @@
+<p>{{count}} articles are tagged <em>{{tag}}</em>:</p> +<ul> + {{#articles}} + <li><a href="/articles/{{id}}/">{{title}}</a> — {{date}}</li> + {{/articles}} +</ul>