Last active
July 27, 2016 10:40
-
-
Save balupton/4166806 to your computer and use it in GitHub Desktop.
DocPad: Automatically set custom Meta Data for items in a Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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