Created
February 10, 2020 22:10
-
-
Save robdodson/fa563e1a0fa87c48a3f699d2f4fa91be to your computer and use it in GitHub Desktop.
This file contains 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
module.exports = (collection) => { | |
return collection | |
.slice(0, 3); | |
}; |
I was thinking something like this, but it feels pretty dangerous:
if (process.env.TEST_ENV) {
eleventyConfig.addCollection('mocks', (collection) => {
// This seems like a bad idea 😈 Creates a fake collection to mutate the collectionApi
collection.items = collection.items.filter((item) => MOCK_POST_SLUGS.includes(item.fileSlug));
// Have to return something so just return collection.getAll
return collection.getAll();
});
}
// ... now all other custom collections start with only the mock posts available to them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
would something like this work?
This will override
collections.recent
no matter how many posts have this tag assigned.