Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
DocPad: Automatically set custom Meta Data for items in a Collection
# Define our Configuration
docpadConfig =
# Define our own Collections
collections:
# Posts
# Anything outputted to the posts directory can be considered a post
# Sort the posts by newest first
# And set their layout to `post` automatically if it isn't already set
posts: (database) ->
database.findAllLive({relativeOutDirPath:'posts'},[date:-1]).on('add', (document) ->
document.setMetaDefaults(layout:'post')
)
# instead of database, you can also use @getCollection('documents') or whatever
# if the content you are filtering are just documents (will be faster if this is the case)
# Export our Configuration
module.exports = docpadConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment