13 June 2021

I use Jbake as static content generator and commentics for comments, I described the reasons in a previous post and here.

In this post is described how I integrate commentics in Jbake templates.

templates/post.ftl

Before the line <#include "footer.ftl">

Add the following lines:

	<#if (config.render_enablecommentics)??>
	<script src="https://ipsedixit.org/commentum/embed.js"></script>
	<div id="commentics"></div>
	<#else>
	<h1>Commentics disabled.</h1>
	</#if>

Makefile

# Used to set up languages in date, like 1 April 2021
export JBAKE_OPTS="-Duser.language=en"

# Rule used to clean previous generated file, prod-site is a folder where I store my final files
clean:
	rm -fR ../prod-site/blog ../prod-site/css ../prod-site/fonts  ../prod-site/js

# Rule used to clean up and create static content
# Set up a environment variable used in post.ftl to render commentics.
build: clean
	export JBAKE_OPTS="-Drender.enablecommentics=true "${JBAKE_OPTS} && jbake -b . ../prod-site

# Rule used to create static content & startup a server @ http://localhost:8820 & watch for changes on files
up:
	rm -fR output && jbake -b -s

So when execute:
* make up --> Environment variable render.enablecommentics is not set and a message show 'Commentics disabled.'
* make build --> Environment variable render.enablecommentics is set and import commentics JavaScript and create div

References