shayla

a simple yet fast static site builder
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/shayla

commit fcd86bd21ae1a8adf0e7a82a332d316255b698a8
parent 9ee696abcfd19305fcaf906812aac448a809866a
Author: Louis Solofrizzo <louis@ne02ptzero.me>
Date:   Thu,  4 Apr 2019 01:26:35 +0200

Html: Add date before indexed posts

Signed-off-by: Louis Solofrizzo <louis@ne02ptzero.me>

Diffstat:
Mshtml.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/shtml.c b/shtml.c @@ -117,11 +117,15 @@ static void index_build_callback(void *unused) html("<ul>"); list_for_each_entry(ptr, &ctx->posts, list) { + char buffer[32] = { 0 }; + struct tm *ptm = localtime(&ptr->ts); + if (!ptr->is_listed) continue; - html("<li><a href='%s%s.html' title='%s'>%s</a></li>", - ctx->root, ptr->route, ptr->summary, ptr->title); + strftime(buffer, sizeof(buffer), "%Y-%m-%d", ptm); + html("<li>%s - <a href='%s%s.html' title='%s'>%s</a></li>", + buffer, ctx->root, ptr->route, ptr->summary, ptr->title); } } html("</div>"); html("</ul>");