Poet – displaying an author link

I’m still fiddling around with poet, the node.js blog generator and it’s really easy to add additional meta information like an author link for collaboratively driven sites.

Assuming you want to power a site with poet as a multi-user blog, you can easily attach the meta information in the individual MarkDown files:

{{{
    "title" : "Amazing Tutorial",
    "tags"  : [ "JavaScript" ],
    "category" : "Sanity",
    "date" : "2013-07-20",
    "author" : { "nick" : "Jonathan", "url" : "http://jonathanmh.com"} // additional line
}}

After that, these informations will directly be available inside your templates when you render the posts. Assuming the views from the example repository, these are changes you could make to your template files:

post.jade:

extends layout

block content
	article.post
		h1
			a(href=post.url)
				= post.title
		span.date #{post.date.getFullYear()}.#{post.date.getMonth()+1}.#{post.date.getDate()}
		- if (typeof(post.author) != 'undefined')
			span.author
				p  by 
					a(href="#{post.author.url}") #{post.author.nick}

		div.post.content
			!= post.content
		div.tags
			- each tag in post.tags
				a(href=tagUrl(tag))
					span.label.label-info #{tag}

includes/postSnippet.jade

div.post
.script(console.log(#{post}))

	h1
		a(href=post.url)
			= post.title
	span.date #{post.date.getFullYear()}.#{post.date.getMonth()+1}.#{post.date.getDate()}
	- if (typeof(post.author) != 'undefined')
		span.author
			p  by 
				a(href="#{post.author.url}") #{post.author.nick}
	article.post.content
		!= post.preview
	div.tags
		- if (typeof(post.tags) != 'undefined')
			- each tag in post.tags
				a(href=tagUrl(tag))
					span.label.label-info #{tag}

With this method, you can add all kinds of meta information, that you might like with your posts 🙂

Poet – a node.js blogging platform

Poet is a great little node.js based project that allows you to start a blog in no time.

TLDR; Put a bunch of MarkDown files in a folder and it’s available as a blog to the rest of the world. I just started a new project for JavaScript and I of course wanted to run it on JavaScript, even before GHOST was released, so I went with Poet.

The description of the project by the author made me smile, so I’ll just quickly share this quote: Continue reading “Poet – a node.js blogging platform”