I am trying to use the featured work collections on a new site I’m building but I am not using the “default” folder structure, which seems to be a major issue.
I have all of my site content under its own tree instead of just in the main src folder.
My folders look like “src/content/services”, instead of “src/services”.
Here is the collection code from my .eleventy.js:
const sortByDisplayOrder = require(’./src/site/utils/sort-by-display-order.js’);
// Returns work items, sorted by display order
config.addCollection(‘services’, collection => {
return sortByDisplayOrder(collection.getFilteredByGlob(’./src/content/services/*.md’));
});
// Returns work items, sorted by display order then filtered by featured
config.addCollection(‘featuredService’, collection => {
return sortByDisplayOrder(collection.getFilteredByGlob(’./src/content/services/*.md’)).filter(
x => x.data.featured
);
});