datedocpad

Formatting post's date value in DocPad


Currently if my post has date: 2013-06-16 in my post, and I do @document.date in the post layout I get "Sat Jun 15 2013 19:00:00 GMT-0500 (CDT)".

I would like to get different formats. Like 2013-06-16 for the pubdate HTML5 tag (or something similar).

Or Jun 15, 2013 for the human readable post date, etc.

How can I accomplish this? BTW my layouts are using the .html.coffee file extension. :)


Solution

  • Figured it out! This is my docpad.coffee file: https://github.com/Greduan/eduantech.docpad/blob/bcc91a247e9741f4ce8aa5883634fac26c9859a5/docpad.coffee#L4-L5 https://github.com/Greduan/eduantech.docpad/blob/bcc91a247e9741f4ce8aa5883634fac26c9859a5/docpad.coffee#L41-L43

    And here's my post template: https://github.com/Greduan/eduantech.docpad/blob/bcc91a247e9741f4ce8aa5883634fac26c9859a5/src/layouts/post.html.coffee#L7-L8

    Of course I only linked the relevant parts of the code. Basically I learned and used Moment.js. :)