barryanders / grav-plugin-blackhole

The static site generator for Grav CMS
Other
169 stars 18 forks source link

Skip generating individual sub-pages of modular pages #18

Closed crittermike closed 7 years ago

crittermike commented 7 years ago

Modular pages in Grav are meant to be viewed as a whole, and each sub-page of them doesn't make sense to be viewed on its own. This PR removes those sub-pages (i.e., parts of modular pages) from the ?pages=all listing that Blackhole uses.

The method for doing this is to just look for /_ in the Grav path for each page, since modular page parts start with underscores, and unset any that exist. That's a little hacky, so better ways would be great, but it worked fine for me.

ghost commented 7 years ago

Here's the options for collecting pages via all(). Would a user want to generate non-visible, modular, non-routable, or non-published pages? Maybe in some situations... I was wondering if just doing published would work. This presents a lot of situations to consider though.

Collection visible() Creates new collection with only visible pages

Collection nonVisible() Creates new collection with only non-visible pages

Collection modular() Creates new collection with only modular pages

Collection nonModular() Creates new collection with only non-modular pages

Collection published() Creates new collection with only published pages

Collection nonPublished() Creates new collection with only non-published pages

Collection routable() Creates new collection with only routable pages

Collection nonRoutable() Creates new collection with only non-routable pages

ghost commented 7 years ago

For now, I'm just going to make it nonModular() and if somebody else comes along and wants to exclude non-visible, non-published, or non-routable pages, then I may add options to let the user choose what they want.

crittermike commented 7 years ago

Great, good point, that's a much cleaner solution!