Simplify collection filtering using `startsWith`

master
Mathias Bynens 2018-08-17 14:11:32 +02:00 committed by GitHub
parent 47403414ad
commit f17db1370c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ module.exports = function(eleventyConfig) {
// only content in the `posts/` directory
eleventyConfig.addCollection("posts", function(collection) {
return collection.getAllSorted().filter(function(item) {
return item.inputPath.match(/^\.\/posts\//) !== null;
return item.inputPath.startsWith('./posts');
});
});