Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
DocPad: Clean dates in post URLs

DocPad: Clean dates in post URLs

Creates URLs like /2012/12/15/merry-xmas for your blog posts.

Requires momentjs to be installed: npm install --save moment

# Import
moment = require('moment')
# Configuration
docpadConfig =
# =================================
# Collections
collections:
posts: ->
@getCollection('documents').findAllLive({relativeOutDirPath:'blog'},[date:-1]).on 'add', (model) ->
dateUrl = moment(model.get('date')).format("/YYYY/MM/DD")+"/"+model.get('basename')
model.addUrl(dateUrl).setsMetaDefaults({url:dateUrl})
# Export
module.exports = docpadConfig
fizzvr commented Apr 17, 2013

DocumentModel has no method 'setsmetaDefaults' :=)
Fix method name to setmetaDefaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment