Skip to content

Instantly share code, notes, and snippets.

@corbanbrook
Created March 6, 2013 15:09
Show Gist options
  • Select an option

  • Save corbanbrook/5099925 to your computer and use it in GitHub Desktop.

Select an option

Save corbanbrook/5099925 to your computer and use it in GitHub Desktop.
var navItems = _.chain(Pressly.Manifest.sections).select(function(section) {
// Select all the sections which are not shallow and..
return !section.shallow && section.assets.length > 0;
}).collect(function(section) {
// Collect assets from these section which includes..
return _(section.assets).detect(function(asset) {
// The first article asset it finds that ..
return asset.type === "article" && asset.children && _(asset.children).any(function(child) {
// Has a a child asset with type of image
return child.type === "image";
});
}) || _(section.assets).first(); // No assets with images were found so use the first asset and use a place holder image
}).value();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment